简体   繁体   中英

Problem with ftp output redirect in SUSE Linux

I am working in a bash script where I need to analyze the output of an FTP session. But I encountered a problem with SUSE Linux FTP client when connecting to an AIX ftp server. The problem is that the output from the FTP command is beign shown on the screen, but is not being send to a pipe if a do a "| grep" or "| awk". Also, if I open the FTP session with a file redirect (ftp -n servername > ftplog.log) the file content after the session is like this:
ftp>
ftp>
ftp>
ftp>
Have anyone encountered this problem? Is there a parameter that I'm missing? I tried redirecting standard error to standard output but it didn't work either.
Thanks

Edit: I am accessing the terminal using Putty SSH, I don't have direct access to the server. I don't think it matters, but just in case...

It is working now.
I was missing the -v parameter for FTP. The documentation is confusing because it states that the -v parameter is the dafault, and it was working as if it was activated (showing all the output in the terminal), but it was not printing it in stdout. When I activated it, the pipes and file redirect started working.
Thanks

You need to redirect stderr AFTER stdout, as in:

ftp -n servername > ftplog.log 2>&1

NOT

ftp -n servername 2>&1 > ftplog.log [wrong!]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM