Question

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...

Was it helpful?

Solution

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

OTHER TIPS

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!]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top