Link to home
Start Free TrialLog in
Avatar of JamesFrog
JamesFrog

asked on

How do I write and use a batch script for ftp in Mac OS X

Hi,

From the terminal in Mac OS X (10.5), I want to carry out several FTP commands without having to wait for each sequential upload - i.e. I want some way of telling the FTP prompt to carry out a list of sequential commands.

These are

1) append /Users/Desktop/MyVid1.flvab MyVid1.flvaa
2) append /Users/Desktop/MyVid1.flvac MyVid1.flvaa
3) append /Users/Desktop/MyVid1.flvad MyVid1.flvaa
4) append /Users/Desktop/MyVid1.flvae MyVid1.flvaa

Each file being uploaded (appended) is 100MB so ideally I want my ftp prompt to sequentially go through the above 4 steps overnight. This will save me waiting 30 minutes or so and then typing in the next 'append' statement.

Is there any way of putting a list of ftp commands in say a txt file and then getting the ftp prompt to execute these steps one by one?

Please help... I have over 3GB of film to upload in this manner and I'm hoping there's an easy way to do this (PS. I'm appending because the server times out on uploads above 100MB and I have no access to change this)

I'm waiting for your help.... please hurry!

Thanks
JAmes

Avatar of DJDecay
DJDecay
Flag of United States of America image

just use the FTP built-in commands


$cd /Users/Desktop/YourFileStorage/
$ftp to.someftp.site.com
220 Your FTP Server
Password:
230 User Logged in
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>bin
220 set to type I
ftp>prompt
Interactive mode off.
ftp>mput *.flvaa

It will upload all your files in sequence.



Avatar of JamesFrog
JamesFrog

ASKER

... the first command need to UPLOAD (put) MyVid1.flvaa

then

the following files need to be APPENDED sequentially to MyVid1.flvaa

.. with the code above, all files will be uploaded but then there's no way of APPENDING them on the server..

The Actual sequence needs to be

1) put (upload) MyVid1.flvaa
2) append /Users/Desktop/MyVid1.flvab MyVid1.flvaa
3) append /Users/Desktop/MyVid1.flvac MyVid1.flvaa
4) append /Users/Desktop/MyVid1.flvad MyVid1.flvaa
5) append /Users/Desktop/MyVid1.flvae MyVid1.flvaa

The above must happen sequentially. I.e

1) file uploads, and ONLY when completed go to 2) etc...
Okay then define a macro

like so


ftp> macdef
(macro name) reappend
Enter macro line by line, terminating it with a null line.
put orig
append stuff1 orig
append stuff2 orig
append stuff3 orig

run the macro like so
ftp>$reappend

this will run those commands in sequence.


as you can see I call the macro up by using a $
This is all new to me so please clarify (as it looks good!)

At the ftp prompt is type in (if the macro was called james)

macdef (james) reappend
put MyVid1.flvaa
append MyVid1.flvab MyVid1.flvaa
append MyVid1.flvac MyVid1.flvaa
append MyVid1.flvad MyVid1.flvaa

when I've typed this in, how do I get back to the

ftp>

prompt to execute the macro?

Thanks
 

ASKER CERTIFIED SOLUTION
Avatar of DJDecay
DJDecay
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for all your help.. one more thing...

What is a 'null line' and how do I create it. From the above I can see it's not enter - so what is it and how do I create one?

Thanks
James

just hit the enter key, thats the null line
That's way cool! - it works a treat... now I can rack up several gigs of uploads and HAVE A LIFE for a few days!!!

Thanks so much for your help!

Best WIshes
James

Thankyou!
You may want to flag it as an accepted solution.
Done. Very much appreciated.
Have fun uploading :-)
.. sorry - seems to be a problem...

I have FTP'd into the server to the folder where I want my macro to run

e.g.

ftp> macdef
(macro name) james
Enter macro line by line, terminating it with a null line
put /Users/Jadmin/Desktop/temp\ append/Seminar1.flvaa

ftp>$james

What I get is

put /Users/Jadmin/Desktop/temp\ append/Seminar1.flvaa
local: /Users/Jadmin/Desktop/temp\ append/Seminar1.flvaa
ftp: local: /Users/Jadmin/Desktop/temp: No such file or directory

....
For some reason the put doesn't start as it seems to want to ftp to my Desktop temp folder as opposed the the ftp server that I'm logged in to ..

Please help again!

Sorry, please ignore the above comment - I wasn't cd's into the correct directory of the video files before ftp'ing