1833792 Members
2159 Online
110063 Solutions
New Discussion

Re: ftp scripts

 
Scott Callicott
Occasional Advisor

ftp scripts

I have some ftp scripts I have created to transfer files from the hp-ux system and an NT system. They work great but I was wondering if anyone knew of away to not display the lines in the script. I have a user name and password in the script that I do not want everyone in the world to know. Any help would be great. Thanks
9 REPLIES 9
linuxfan
Honored Contributor

Re: ftp scripts

Hi Scott,

you could create a .netrc file in your home directory (permissions should be 400 (chmod 400 .netrc)
Include this in your .netrc file
/Begin
machine login user passwword passwd
/End/

eg:
machine 192.168.10.1 login user1 password welcome


-HTH
Ramesh
They think they know but don't. At least I know I don't know - Socrates
Patrick Wallek
Honored Contributor

Re: ftp scripts

Have you thought about using a .netrc file to automate the ftp login? That would allow to delete the user name and password lines from the script.

A .netrc file must have permissions of 600 (rw for the owner ONLY) and be created in the owners home directory.

The syntax is:

machine mickey login minnie passwd mouse
Dave La Mar
Honored Contributor

Re: ftp scripts

Ditto the first two replies.
Have instituted this here and found it to be secure and easily managed.
dl
"I'm not dumb. I just have a command of thoroughly useless information."
Scott Callicott
Occasional Advisor

Re: ftp scripts

Thank you for the input. The only down fall to this process is we are talking about 150 remote users. I was hoping for a switch that I did not know that would not display the lines of script.
Patrick Wallek
Honored Contributor

Re: ftp scripts

Something else you could do is write a wrapper script for cat and more that would get executed before the real cat / more that does something like:

#!/sbin/sh
if [ $1 = 'filename' ]
then
echo "Can't do it"
else
/usr/bin/cat $1
fi

The above script will look at the parameter passed to the script and if it matches 'filename' then it will not cat the file. If it does not match then it will invoke the real cat and you can read the file. You would put this script as 'cat' in some directory that is at the beginning of all the users path so that it gets found before the 'cat' in /usr/bin.

This is a bit simplistic, but hopefully you get the idea.
Scott Callicott
Occasional Advisor

Re: ftp scripts

Sorry I was not complete on my info. The scripts are running on the NT side not on the HP-UX side.
linuxfan
Honored Contributor

Re: ftp scripts

Hi Scott,

I am a little confused, you are ftp'ing files from HP to NT. and you have 150 users, so are you giving the password of 150 users in the script? why not ftp as root?

Also what do you mean display the lines of source?

Also Patrick, your solution would be fine as long as you use cat, what about pg, more , less ? Also the user can copy the file to a different name.

-Regards
Ramesh
They think they know but don't. At least I know I don't know - Socrates
Scott Callicott
Occasional Advisor

Re: ftp scripts

Ok the script is running on the NT systems. There are 2 different scripts one to put info onto the Unix box and another to pull the info off. I am using the root to ftp that is why I do not want the user name and password to be seen in the script everytime it is ran.
Wodisch
Honored Contributor

Re: ftp scripts

Hello Scott,

I just verified that:
running "ftp -v -s:input.txt SERVER" in a DOS-box on the
windows side did what you wanted...

The input file "input.txt" is attached.

HTH,
Wodisch