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

JamesFrogAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DJDecayCommented:
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.



0
JamesFrogAuthor Commented:
... 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...
0
DJDecayCommented:
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.


0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

DJDecayCommented:
as you can see I call the macro up by using a $
0
JamesFrogAuthor Commented:
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
 

0
DJDecayCommented:
Not quite

this is exactly what you type: (macro name) is a prompt <enter> is just hitting the return key without typing.
--cut here--

ftp>macdef <enter>
(macro name) reappend
put MyVid1.flvaa
append MyVid1.flvab MyVid1.flvaa
append MyVid1.flvac MyVid1.flvaa
append MyVid1.flvad MyVid1.flvaa
<enter>
ftp>$reappend


--cut here--

I just selected reappend as a good name that does not clash with anything.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JamesFrogAuthor Commented:
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

0
DJDecayCommented:
just hit the enter key, thats the null line
0
JamesFrogAuthor Commented:
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

0
JamesFrogAuthor Commented:
Thankyou!
0
DJDecayCommented:
You may want to flag it as an accepted solution.
0
JamesFrogAuthor Commented:
Done. Very much appreciated.
0
DJDecayCommented:
Have fun uploading :-)
0
JamesFrogAuthor Commented:
.. 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!

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

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Server Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.