Now, on the flip side, comes the hard part. The FTP server has a connection timeout. IE if I log on, the connect will only last 5 idle minutes and then drop. What could I do to initiate the FTP connection once the data starts being received through the file handle? I could do
while(<FILEHANDLE>) { $ftp = Net::FTP->new "10.206.15.30"; $ftp->login( "uname", "pass" ); $ftp->append( *FILEHANDLE, "remotefile.dat" ); $ftp->quit; } This would probably work, but would bombard the FTP unneccesarily with connections. Can I do something like: if( <FILEHANDLE> ) { other stuff . . . } And maybe that would enter the code block once the data starts streaming? -----Original Message----- From: Balint, Jess [mailto:[EMAIL PROTECTED]] Sent: Monday, April 15, 2002 3:38 PM To: 'Timothy Johnson' Cc: '[EMAIL PROTECTED]' Subject: RE: Sending Command Output over Net::FTP Ah yes, good call. I think I can still use open, like this: open( OUTPUT, "sqlrun file.sql 2> $$.log |" ); bla bla bla print "No error" if( -z $$.log ); Thanks! -----Original Message----- From: Timothy Johnson [mailto:[EMAIL PROTECTED]] Sent: Monday, April 15, 2002 3:34 PM To: 'Balint, Jess'; 'Nikola Janceski' Cc: '[EMAIL PROTECTED]' Subject: RE: Sending Command Output over Net::FTP Do you NEED the return code from the system call? Is there some text returned when you perform the query to determine if it was successful? If so, you can just use backticks and parse the output first to see if it was successful. $output = `sqlrun mysqlfile.sql`; $output =~ /failed/ || ftpsend($output); -----Original Message----- From: Balint, Jess [mailto:[EMAIL PROTECTED]] Sent: Monday, April 15, 2002 12:28 PM To: 'Nikola Janceski' Cc: '[EMAIL PROTECTED]' Subject: RE: Sending Command Output over Net::FTP I think open() is giving me the process ID of the query. Is there any way to pipe the output of a system command to a filehandle? Or even stdout? -----Original Message----- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Monday, April 15, 2002 3:24 PM To: 'Balint, Jess'; Nikola Janceski Cc: '[EMAIL PROTECTED]' Subject: RE: Sending Command Output over Net::FTP yes... but I don't think you are checking the exit status if that's all you are doing, don't know much about the bit status it returns but it's the same for system and open for a command. > -----Original Message----- > From: Balint, Jess [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 15, 2002 3:12 PM > To: 'Nikola Janceski' > Cc: '[EMAIL PROTECTED]' > Subject: RE: Sending Command Output over Net::FTP > > > Can I still receive the exit code from that command that way? > That is how I > am testing if the query ran correctly. Hence: > > $code = system( "sqlrun mysqlfile.sql" ); > print "Error" if $code; > > -----Original Message----- > From: Nikola Janceski [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 15, 2002 3:17 PM > To: 'Balint, Jess'; '[EMAIL PROTECTED]' > Subject: RE: Sending Command Output over Net::FTP > > > you probably want to use open(); > > open(COMMAND, " |") or die "cannot execute: $!"; > while(<COMMAND>){ > #ftp stuff > } > > > > -----Original Message----- > > From: Balint, Jess [mailto:[EMAIL PROTECTED]] > > Sent: Monday, April 15, 2002 3:05 PM > > To: '[EMAIL PROTECTED]' > > Subject: Sending Command Output over Net::FTP > > > > > > Hello all, now that this works . . . > > I am trying to send the output from a database query over and > > FTP connection > > into a remote file. When I run it like: > > > > sqlrun mysqlfile.sql | myperlscript.pl > > > > It seems to work alright. What I would like to do is have the > > perl scripts > > kick off the query through a system( ) call and then feed the > > output into > > the FTP connection. This is the one that works: > > > > sql -d ltd01 -f q1.sql | > > perl -e ' > > use lib qw( /qmds/mydir/perl/lib/site_perl/5.005/ ); > > use Net::FTP; > > while( <> ) { > > $ftp=Net::FTP->new("10.206.15.30"); > > $ftp->login("mydomain\\myname","mypass"); > > $ftp->cwd("/myhome/mydirectory"); > > $ftp->put(*STDIN,"myfile.txt") > > or die("error!\n"); > > $ftp->quit; > > } > > ' > > > > What could I use as the filehandle for the output from the > > system command? > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -------------------------------------------------------------- > -------------- > -------------------- > The views and opinions expressed in this email message are > the sender's > own, and do not necessarily represent the views and opinions of Summit > Systems Inc. > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > ---------------------------------------------------------------------------- -------------------- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]