[ACCEPTED]-Controlling psftp in a Windows Batch File-batch-file
I ended up creating a new batch file from 1 the main one that I then told psftp to use:
echo cd downloads/boxee > psftp.bat
echo put "%1.avi" >> psftp.bat
echo quit >> psftp.bat
psftp frontrow@192.168.1.50 -pw aaa -b psftp.bat
Specify a file containing batch commands
In 13 normal operation, PSFTP is an interactive 12 program which displays a command line and 11 accepts commands from the keyboard.
If you 10 need to do automated tasks with PSFTP, you 9 would probably prefer to specify a set of 8 commands in advance and have them executed 7 automatically. The -b option allows you 6 to do this. You use it with a file name 5 containing batch commands. For example, you 4 might create a file called myscript.scr 3 containing lines like this:
cd /home/ftp/users/jeff
del jam-old.tar.gz
ren jam.tar.gz jam-old.tar.gz
put jam.tar.gz
chmod a+r jam.tar.gz
quit
and then you 2 could run the script by typing
psftp user@hostname -b myscript.scr
Credit to 1 http://the.earth.li/~sgtatham/putty/0.52/htmldoc/Chapter6.html#6.1.3
All in one file:
@echo off
echo Convert and Upload to Apple TV file Called %1.mkv
ffmpeg -i %1.mkv -vcodec mpeg4 -acodec ac3 -ab 384k -sameq -s hd720 -t 60 %1.avi
(
echo cd downloads/boxee
echo put %1.avi
echo quit
) | psftp frontrow@192.168.1.50 -pw aaa -bc
If we need the precise port 1 number:
psftp frontrow@192.168.1.50 -P 222 -pw aaa -bc
Why not use the built in FTP command that 5 comes with windows?
you will need to write 4 a script that will upload the file:
open 192.168.1.50
user
frontrow aaa
put file.avi
quit
then 3 call ftp -s:MyScript
You will need to generate 2 the script per each file using echo and 1 the >> redirector.
I was struggling to run a simple batch file/script 17 to have an end user upload a file she had 16 just edited to a secure FTP site.
Using This 15 Script:
cd /outgoing
put Examplefile.txt
# chmod a+r Examplefile.txt
# ren Examplefile.txt Exam.ted
# rm Examplefile.txt
quit
and running PuTTY's sftp command 14 from a standard Windows command prompt:
psftp user@ftp.address.com -pw password -b testscript.scr
I 13 was able to quickly and (more importantly!!) easily 12 upload a file from the company I am doing 11 work for to a company we needed to transact 10 business with. You can also see I am ready 9 to rename the file if needed (ren
) or delete 8 a file if needed (rm
). The hash symbol (#
) sets 7 the lines as remark lines.
This allowed me 6 to create a complete batch file in Windows 5 that the end user could simply click on 4 to upload the files as she generated them. It 3 was MUCH simpler than using some of the 2 other "flavors" of sftp I found on the 'Net 1 and I have used and trusted PuTTY for decades.
If all you're doing with ftp is uploading 1 a single file, you can use pscp.
echo Convert and Upload to Apple TV file Called %1.mkv
ffmpeg -i %1.mkv -vcodec mpeg4 -acodec ac3 -ab 384k -sameq -s hd720 -t 60 %1.avi
pscp -pw aaa -sftp %1.avi frontrow@192.168.1.50:/downloads/boxee
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.