ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language 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 don't understand why I'm getting different redirections "report.ftp" when I send the ftp command via ssh and when I do the ssh directly from the remote host!
With ssh I do the following:
Code:
echo ""; while read machine; do echo "We are testing $machine"; ssh -n -i ~/rsa_key myexper_test@$machine 'ftp 211.5.25.10 > report.ftp'; done < list
The file is transferred but the report.ftp only contained:
Code:
$ cat report.ftp
WARNING! 22955 bare linefeeds received in ASCII mode
File may not have transferred correctly.
When I log to the remote and do the ftp from there with the same command sent via ssh:
Code:
ftp 211.5.25.10 > report.ftp
I get the full report.ftp correctly:
Code:
$ cat report.ftp
Connected to 211.5.25.10 (211.5.25.10).
220 (vsFTPd 2.0.5)
331 Please specify the password.
230 Login successful.
cd ping/thr
250 Directory successfully changed.
get TEST.mp3
local: TEST.mp3 remote: TEST.mp3
227 Entering Passive Mode (211,5,25,10,99,198).
150 Opening BINARY mode data connection for TEST.mp3 (5492819 bytes).
WARNING! 22955 bare linefeeds received in ASCII mode
File may not have transferred correctly.
226 File send OK.
5492819 bytes received in 22.9 secs (239.37 Kbytes/sec)
quit
221 Goodbye.
antegallya: the commands are as above. The first and second codes are the ftp command over ssh and the cat of its saved file on the remote host. The third and forth codes are the ftp command executed directly on the remote host and its saved file.
Yes, I understood what are the different ways you use to start the ftp session. But how are the ftp username, password, cd, get and quit issued ? Do you enter them manually ?
Did you already try removing the "-n" option of your ssh batch command ? You know it redirects stdin from /dev/null, right ?
Does your bash does any configuration specific things at login ? I mean configuration that may change the behavior of your ftp connection in your .bashrc or .bash_profile. As issuing an ssh command directly as you do does not open a login shell.
Yes, the login info for ftp over the ssh are automated using .netrc file, and also with the direct ftp (i.e., the second one), the login info are automated using the same .netrc file. No specific bash configuration is implemented.
schneidz: On the testbed I'm working on, both ssh and scp are ONLY allowed between my private machine (i.e., not a node in the experiment). I have no permission to use ssh or scp between remote nodes.
the first thing i dont understand is if you got ssh installed why dont you use scp instead of ftp ?
I assume ali2011 wants each of its remote machines to retrieve some file from a central ftp server and get the result logged (on each machine again, independently). Scp is thus no option.
ali2011, I'm okay with all the login stuff. But I don't understand how you issue your "get" and "quit" commands to the ftp shell.
But anyway, that doesn't matter. Your problem is that there's an undocumented behavior of the ftp command : it checks if stdin is coming from a tty. If not, it goes into silent mode.
Adding -v for verbose should do the trick, but you won't have the prompt printed in your output file.
Another trick is using the "script" command to fake a tty like that :
antegallya, the get and quit command are issued from macro in the .netrc file.
Code:
machine IP-Address login user_name password user_pass
macdef init
cd test
get file.txt
quit
BTW, I did try the (ssh -n -i ~/rsa_key myexper_test@$machine "script -c 'ftp 211.5.25.10 &> report.ftp'"), and no file is printed with name report.ftp. While when I issued the (script -c 'ftp 211.5.25.10 &> report.ftp') without ssh-ing directly on the remote host the result is OK!
I didn't knew about macdef, you taught me something here, thanks.
I hope it works with the verbose option because I've got no clue why it doesn't work with "script". I'm afraid we're encountering a "it works for me" situation here.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.