• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 756
  • Last Modified:

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

0
JamesFrog
Asked:
JamesFrog
  • 8
  • 7
1 Solution
 
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
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 
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
 
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now