CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate: Re: [Mark1110] help with scp command: Edit Log

Veteran / Moderator

Aug 19, 2011, 4:38 PM

Views: 2635
Re: [Mark1110] help with scp command

First, add the warnings and strict pragmas and declare your vars, which is done by prefixing them with the 'my' keyword. And don't use CamelCase naming. Use an _ underscore to separate the words.

Next, get rid of those 2 subs. They are a very messy way of formatting the date string. Use the strftime function from the posix module.

Don't use the backticks operator in void context. The backticks are used to capture the output of an external command, which you're not doing. If you don't want to capture the output of the scp command, then use the list form of the system function or one of the IPC::Open modules.

use strict; 
use warnings;
use POSIX qw(strftime);

my $tran_filename = strftime("/broker/user/csp/myTestFile_%Y%m%d.txt", localtime);

my @cmd = qw($tran_filename;

system(@cmd) == 0 or die "system '@cmd' failed: $?;

In this case, I'd probably use the Net::SCP module instead of the system call.

(This post was edited by FishMonger on Aug 19, 2011, 4:43 PM)

Edit Log:
Post edited by FishMonger (Veteran) on Aug 19, 2011, 4:41 PM
Post edited by FishMonger (Veteran) on Aug 19, 2011, 4:43 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives