Discussion Locked

FTP

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

We receive files with our Sun Solaris box and want to forward them to our HP 3000 (MPE 5.5) via ftp. The application will automatically run a shell script but due to fact that I can not write anything that will allow me to log on to the HP 3000, I have to ftp these files manually. For example, in my shell script I have the following:

#!/bin/ksh
ftp ###.###.###.###
user useraccount
put file

It seems that I will need a command somewhere between the first and second line that will allow the HP 3000 to wait for the input of the shell script. Anyone see where I'm falling short? Thanks

Brian

5 replies

by stillatit

Try it this way:

Create a file (on the fly) named 'myexecutefile' with the following lines:

open ###.###.###.###
user myname mypass
bin
put myfilename
bye

Then execute:
ftp -n < myexecutefile

That should do it. You could presumably set up a .netrc file rather than include user and password.

Good luck.

by cpfeiffe

You can also try to use a FTP macro designed for these types of things.

On the Sun server, in the home directory of the account you are using to transfer the files create a file called .netrc. Issue a chmod 600 .netrc. This is very important. .netrc must be owned by the person whom's home directory you are putting it in, and musr be readable/writeable by that user and that user only to work.

Within .netrc type the following:
machine $IP_of_HP_machine
login $user_account_on_HP_machine
password $password_for_account_on_HP_machine
macdef init
bin
prompt
cd $directory_on_hp_machine_to_put_files_in
lcd $directory_files_are_in_on_Sun_server
mput *
bye

NOTE: It is important to add two blank lines at the end of this macro. Everything that is followed by the $ will be specific to your case. bin, prompt and mput/put methods are optional. You should treat the lines after the macdef init line as you would if you were in the active FTP session. You will need to use the cd and lcd part, regardless of what directory you are in when you open the FTP session.

Once it is created you can just type ftp $IP_of_HP_machine and it will use the macro to do what you have told it to. When you are done you can remove this file, as it will always be used when you ftp to the HP machine from the Sun machine as the user whom's home directory you put it in. It also wouldn't be good security to leave it laying around with a plain text password in it.

Good luck.

This discussion is closed to new replies.