Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need a continuous ftp file upload between two computers.
I have a shell script that runs fine, it gets files in /myuser/MYFILES
, reads the user and passwd from /home/myuser/.netrc and does the transfer fine.
The problem arises when I want to robustify this: I want the script
in inittab, so that if there is a problem, say a maintenance shutdown,
the process will be running whenever the machine is up again.
So I put the script in inittab and it does not work. To debug,
I logged in as root and tried /myuser/ftpscript
(which works fine when I log in as myuser)
and I get a user+password prompt, which means it does not see .netrc, since inittab is not running as myuser(and chmod 666 will not do). So I copied .netrc to / as 600, got nowhere and then remembered that the home
of root is /root in modern systems, so I copied it to /root instead (owner root, group sys, mode 600), but I still get the prompt.
Most likely root cannot use ftp (that's the default in all distros). If you want root to use ftp then edit /etc/ftpusers in server and remove root. Also check if your ftp server software configuration denies root access.
No, I can ftp to the same ip as root, fine. It even finds the user name and password from .netrc, so I do not have to type in anything
other than ftp destination_ip. It is when I run the script as root that I get the prompt
ftp 172.16.167.5 <<**
echo "opened ftp"
#<<**
cd /home/myuser/MYFILES
echo "cdd to MYFILES"
put /myuser/MYFILES/testx.gz /home/remote_user/MYFILES/$oldfile.gz
echo "put file">>/myuser/var/DONEALL
#quit
bye
The fact is that this snippet it's not working for me until I remove all the lines that are not ftp commands (i.e. the comments and the echo statements).
Then it works as expected!!! Perhaps you should try just the above snippet to make it work and then add the rest of the commands.
as myuser automaticall connects you to the remote site, no user names and passwords asked
Doing the same as root wants user name and password.
This is what needs to be fixed. Apparently copying .netrc to /root
will not do it.(BTW, the remote machine is linux, this one
is HP-UX, but it should make no difference)
No, I can ftp to the same ip as root, fine. It even finds the user name and password from .netrc, so I do not have to type in anything
and then
Quote:
The real issue is that doing
ftp 172.16.167.5
as myuser automaticall connects you to the remote site, no user names and passwords asked
Doing the same as root wants user name and password.
I am still thinking that root cannot ftp to the server as it's normal in a default installation. But you can use in root's .netrc the username/password of the user you want, so root runs your scripts and then connects to the ftp server as that user:
In my experience normal is that you should not ftp TO root. At any rate
the point is that root does not respect the .netrc file, even if
I put in in /root. There should be a way to override this, but I am not sure how it's done and I have been unable to find this
At any rate
the point is that root does not respect the .netrc file, even if
I put in in /root.
I'm not familiar with HP-UX, but I guess that since a normal user can use .netrc, so can root. Perhaps /root is not root's homedir.
Another thing you can do is to use "su myuser" before invocing ftp in your script.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.