me again :P
I have some problems with some bat file, that bat file , connects to and ftp and download all files from a remote folder, then delete it, but my problem/question is: i need a txt(log) of every file before download it from the remote server, here is my file
bat file:
ftp -i -s:ftpfile.txt site.com
txt file
user-name
user-pass
lcd c:\localfolder\some\folder
cd remotefolder-name
mget .
mdelete \\remotefolder-name\ .
quit
If i use the >>mylog.txt on this line:
ftp -i -s:ftpfile.txt site.com>>mylog.txt
I get some extra data that i dont want to. I just need the file names before download it, something like this:
log.txt
file001x.xml
filedfx.xml
file023x.xml
filed33x.xml
Ps:sorry for my english ;)
You may redirect ls output to local file. Syntax is: ls pattern local_file. An example would be: ls * ftplist.txt or ls . ftplist.txt. Both will produce a file ftplist.txt (in local current directory if you do not specify path) with a list of files (and possibly subdirs) in current directory on remote server (in slightly different formats)
Related
I want to create a batch/shell script for windows and mac that will take few different files with different types and will compress it to a .zip file.
I already saw a few questions and answers about it, but all of them either compress all the files in the folder or compress them individually.
Example (look at attached image):
I have a folder that contains 1.txt, 2.xml, a sub directory.
And I want to turn all of them into a .zip file.
If possible to get a solution both for windows and Mac.
On Windows there is the file 7zip.chm in directory %ProgramFiles%\7-Zip which is the help file of 7-Zip. Double click on this file to open the help.
On Contents tab there is the list item Command Line Version with the help pages:
Syntax ... Command Line Syntax
Commands ... Command Line Commands
Switches ... Command Line Switches
The target is to compress everything in folder test into a ZIP file with name of the folder as file name.
This could be done for example with the command line:
"%ProgramFiles%\7-Zip\7z.exe" a -bd -mx=9 -r -y -- test.zip "C:\Path to Directory\test\*"
This command line adds (a) everything in directory C:\Path to Directory\test recursive (-r) to a ZIP file with name test.zip in current working directory without progress indicator (-bd) using best ZIP compression (-mx=9) with assuming Yes on all queries (-y).
In other words the file test.zip in current directory contains after execution the subdirectory main with everything inside and the files 1.txt and 2.xml.
I am trying to use a cmd file to run a batch file that uploads a file of mine to a directory of my website. The batch file looks like this:
open ip address
username
password
option confirm off
cd \public_html\wp-content\uploads\2014\07
put "C:\Users\a\Documents\pdf\Contact Info.pdf"
quit
The cmd file looks like this:
ftp -s:c:\Users\a\Documents\upload.bat
When I run the cmd file I get output in command prompt that says that my username and password are ok and then tells me that option confirm off is an invalid command and that the cd filepath is a prohibited file name. It then says my file is uploaded but I can't find where the file is put. Is there a reason why this is happening? Is it possible to upload the file to that directory?
Use winscp. Download: http://winscp.net/eng/download.php
option confirm off is a valid WinSCP command, see http://winscp.net/eng/docs/scriptcommand_option
Example: Uploading a single file with WinSCP
http://winscp.net/eng/docs/script_upload_single_file
Step 1
create file: winscp-upload-script.txt
option batch abort
option confirm off
open sftp://username:password#example.com/
put "C:\Users\a\Documents\pdf\Contact Info.pdf" \public_html\wp-content\uploads\2014\07
exit
Step 2
create file: do-upload.bat
"C:\Program Files (x86)\WinSCP\winscp.com" /script=winscp-upload-script.txt
Step 3
Go scheduler, create new task, like described here (http://www.sevenforums.com/tutorials/12444-task-scheduler-create-new-task.html) and use do-upload.bat and configure event timing.
-Done-
My .sh file starts like this:
curl --cookie-jar cookies.txt "url"
When I run this .sh file directly from Cygwin it properly creates the cookies.txt file. However when I call the .sh file via a .bat file, the curl commands work, but the .txt file is not created.
My batch file looks like
#echo off
c:
chdir c:\cygwin64\bin
bash --login -i -c curl_test.sh
Why is the text file not created?
The issue was I did not include the path. When I referenced the .txt file I need to first do /bin/cookies.txt whereas when doing it from bash directly you do not.
I want to encrypt files using GnuPG. I have written a .bat file to do that. The contents of the bat file is like
gpg --trust-model always --recipient aaa#yyy.com --encrypt File_name
when the file i want to encrypt is on my local machine this works fine.
but what i want is to encrypt a file that is on a shared path (without copying to my local machine). when i give the File_name as \\shared_path\File_name i get gpg: file not found error.
Any sort of help is appreciated.
Perhaps gpg cannot handle UNC paths. Try using PUSHD to temporarily change your directory to the UNC path
pushd \\shared_path
gpg ...
popd
I need to do a downloadable Windows batch file (.bat) which runs lpr command on clients machine. That's easy. The hard part is that the batch file must include the data to be printed also. Everything needs to be in one downloadable-file that could be ran by the enduser.
Is there any way to include .prn file (Print-to-file -file) in batch file? Or can I somehow include the printer data on lpr command?
Thanks!
As far as know you cannot include print data in your lpr command. You can specify the file to print and that is it. But do you know the printer name of all the clients? It sounds like there might be a better way of deploying if the clients are on the same network.
You cannot include a .prn file in a .bat (or .cmd) file in any reasonable way (even if the .prn file is a text file). Again if clients are on the same network the .bat file (or .cmd) could access the .prn file stored in a shared place.
Lpr: Sends a file to a computer
running Line Printer Daemon in
preparation for printing.
Syntax
lpr [-S ServerID] -P PrinterName [-C
BannerContent] [-J JobName] [{-o | -o
l}] [-d] [-x] FileName
"The hard part is that the batch file must include the data to be printed also. Everything needs to be in one downloadable-file that could be ran by the enduser."
I'm a little unclear on this, however to me it sounds like you want the batch script to include the text of the data you wish to print?
It looks as if you can have the information in say a .txt file and pass it through lpr:
lpr -P printername -x file.txt
If you need information from a .prn file inside of this printed .txt file, you can try:
TYPE file.prn>>file.txt
However not sure if TYPE will work on a .prn file.