Ask a Question related to PERL Miscellaneous, Design and Development.
-
Nathan Pryor #1
caturing ftp standard output while using system() and cron
I need to capture all standard output of an ftp session that is run
inside a perl program. Short example:
#!/usr/bin/perl
system("ftp -i ftp.gnu.org > results");
I use a .netrc file to list the commands for the ftp session:
machine ftp.gnu.org
login anonymous
password [email]mrtortoise@yahoo.com[/email]
macdef init
lcd /tmp
ls
pwd
bye
I have no problems capturing all standard output, both local and
remote, when I run the script from the command line. However, when I
run the script using a cron job only the standard output from the
remote host shows up in the file. In my real script I am using "mput"
to send several files to the remote host so I need to see the local
standad output in order to verify all files transferred successfully.
Any suggestions?
Perl version: This is perl, v5.6.1 built for i386-linux
Nathan Pryor Guest
-
Some 'System Calls' was Capturing system call output value
On Friday, Nov 14, 2003, at 18:39 US/Pacific, Jerry Rocteur wrote: Wiggins is the one who deserves the point, since he was the one with the... -
Capturing system call output value
perldoc -q 'output of a command' You want backticks instead, though there are better ways to come by the sysem name, and don't use $a.... ... -
Help with "A specified file does not support the ioctl system call." in cron
david.n.moreno@lmco.com (Dave Moreno) writes: Without seeing a copy of the script, I'm not sure anyone will be able to assist you. Best... -
Ncurses output started from cron
Dear Charles, just an idea: what if you use "expect" within a shell- script that has been started by cron??? An idea, nothing more, nothing less... -
system has started e-mailing me, cron demon
Hello, I have started to get the following message e-mailed to me at night. Envelope-to: web@debian From: root@debian (Cron Daemon) To:... -
Thens #2
Re: caturing ftp standard output while using system() and cron
On 11 Sep 2003 09:17:31 -0700
[email]mrtortoise@yahoo.com[/email] (Nathan Pryor) wrote:
# I need to capture all standard output of an ftp session that is run
# inside a perl program. Short example:
#
# #!/usr/bin/perl
# system("ftp -i ftp.gnu.org > results");
Why dont you use Net::FTP and save yourself the trouble of Portability
and other issues.
The thumb rule is use perl modules wherever you can.
Regards,
Thens.
Thens Guest
-
James Willmore #3
Re: caturing ftp standard output while using system() and cron
On 11 Sep 2003 09:17:31 -0700
[email]mrtortoise@yahoo.com[/email] (Nathan Pryor) wrote:You're redirecting STDOUT to a file ('>') - use 'tee' to see both> I need to capture all standard output of an ftp session that is run
> inside a perl program. Short example:
>
> #!/usr/bin/perl
> system("ftp -i ftp.gnu.org > results");
STDERR and STDOUT -and- redirect STDOUT to a file ;)
<snip><snip>> I have no problems capturing all standard output, both local and
> remote, when I run the script from the command line. However, when
> I run the script using a cron job only the standard output from the
> remote host shows up in the file. In my real script I am using
> "mput" to send several files to the remote host so I need to see the
> local standad output in order to verify all files transferred
> successfully. Any suggestions?
perldoc -q "Why can't I get the output of a command with system()?"
perldoc -q "How can I capture STDERR from an external command?"
So, basically, you could do ...
==untested==
#notice there's no '> results'
open(CMD, "ftp -i ftp.gnu.org |");
my @results = <CMD>;
close CMD;
You could also look at the Net::FTP module ;)
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. [url]http://www.gnu.org/licenses/gpl.txt[/url]
for more information.
a fortune quote ...
A language that doesn't have everything is actually easier to
program in than some that do. -- Dennis M. Ritchie
James Willmore Guest
-
Dave Saville #4
Re: caturing ftp standard output while using system() and cron
On Thu, 11 Sep 2003 21:53:51 +0530, Thens wrote:
Assuming you know that there *is* one :-)>On 11 Sep 2003 09:17:31 -0700
>mrtortoise@yahoo.com (Nathan Pryor) wrote:
>
># I need to capture all standard output of an ftp session that is run
># inside a perl program. Short example:
>#
># #!/usr/bin/perl
># system("ftp -i ftp.gnu.org > results");
>
> Why dont you use Net::FTP and save yourself the trouble of Portability
>and other issues.
>
> The thumb rule is use perl modules wherever you can.
Regards
Dave Saville
NB switch saville for nospam in address
Dave Saville Guest
-
Tintin #5
Re: caturing ftp standard output while using system() and cron
"Dave Saville" <dave.nospam@ntlworld.com> wrote in message
news:qnirfnivyyragyjbeyqpbz.hl2m0um.pminews@text.n ews.ntlworld.com...Hence the reason everyone uses [url]http://search.cpan.org/[/url]> On Thu, 11 Sep 2003 21:53:51 +0530, Thens wrote:
>>> >On 11 Sep 2003 09:17:31 -0700
> >mrtortoise@yahoo.com (Nathan Pryor) wrote:
> >
> ># I need to capture all standard output of an ftp session that is run
> ># inside a perl program. Short example:
> >#
> ># #!/usr/bin/perl
> ># system("ftp -i ftp.gnu.org > results");
> >
> > Why dont you use Net::FTP and save yourself the trouble of Portability
> >and other issues.
> >
> > The thumb rule is use perl modules wherever you can.
> Assuming you know that there *is* one :-)
Tintin Guest
-
Nathan Pryor #6
Re: caturing ftp standard output while using system() and cron
<snip>
I'm looking at the module now. Thanks for the tip everyone.>> >> > >
> > > Why dont you use Net::FTP and save yourself the trouble of Portability
> > >and other issues.
> > >
> > > The thumb rule is use perl modules wherever you can.
> > Assuming you know that there *is* one :-)
> Hence the reason everyone uses [url]http://search.cpan.org/[/url]
Nathan Pryor Guest



Reply With Quote

