1833588 Members
4198 Online
110061 Solutions
New Discussion

FTP Scripts

 
John Donaldson
Occasional Contributor

FTP Scripts

I am trying to script a simple FTP session and cannot find any sample scripts out there specific to HP-UX. I've got the login automated in my .netrc file but when I try to pipe my put via << EOF, I get "?Invalid command" and only when I issue a bye does it return to the rest of the script which is basically switching to ascii transfer type and then my put. I know, really simple but I can't get it to work. Any suggestions other than find a new field to work in ;> would be appreciated. Thanks - JD
What error message?
5 REPLIES 5
Curtis Larson
Trusted Contributor

Re: FTP Scripts

there have been quite a few questions in the past in regards to automating ftp. A good starting point would be to search the forums for previous answers.
Patrick Wallek
Honored Contributor

Re: FTP Scripts

Here is another way to do it:

The following can be in your script that does the automatic ftp. You can take out the redirection to $LOGFILE, that just gives you a log of what is occurring. It is nice for debugging though. The '$ eft' executes the eft macro that is defined in the .netrc file. The .netrc file is included below.

ftp -i -v 1xxx.xxx.xxx.xxx >> $LOGFILE 2>&1 << ENDFTP
$ eft
ENDFTP

***************
contents of .netrc file
*****************
machine xxx.xxx.xxx.xxx login username password user_password
macdef eft
binary
mput filenames
put filename
quit
James R. Ferguson
Acclaimed Contributor

Re: FTP Scripts

John:

Take a look at this thread and the threads it references for some different ways to create FTP scripts:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x82dff841489fd4118fef0090279cd0f9,00.html

...JRF...
John Donaldson
Occasional Contributor

Re: FTP Scripts

Thanks to all for the help. - JD
What error message?
Wodisch
Honored Contributor

Re: FTP Scripts

Hello John,

why do all make it so difficult? Inside ".netrc" is exactly
one macro that will be executed automagically, and its
name is "init".
Try a ".netrc" like

machine MMM login uuu password PPP macdef init
cd /foreign-dir
lcd /local-dir
bin
prompt
mget *
quit

It MUST end with an empty line (all macros have to).

HTH,
Wodisch