I have two servers - A and B, I want B to connect to A and pull all the .tgz files it sees in a directory.
I have the process working if I hard code the paths and servernames etc but cannot get to work using variables. Here are my two scripts:
#!/usr/bin/perl -w
my $esxbackupserver = '192.168.110.235';
my $sftpfile = '/vmfs/volumes/Data2/backup/sftpfile';
my $sftp = 'sftp';
system $sftp, '-b', '$sftpfile','$esxbackupserver';
The second file (sftpfile) is the command for sftp
cd /vmfs/volumes/Software/Backup
get *.tgz
When I run the script I get:
No such file or directory ($sftpfile).
As I say, hard coded it works fine but being a newbie to Perl I am obviously overlooking something - can anyone help? Thanks
Message was edited by:
RDPetruska
Removed emoticon from subject line
you should change single quote to double quote, since if you use single quote, the variable will not be resolved and the system will regard it as a hard coded string,
just change it from:
system $sftp, '-b', '$sftpfile','$esxbackupserver';
to
system $sftp, '-b', "$sftpfile","$esxbackupserver";
i am sure it will works.
you should change single quote to double quote, since if you use single quote, the variable will not be resolved and the system will regard it as a hard coded string,
just change it from:
system $sftp, '-b', '$sftpfile','$esxbackupserver';
to
system $sftp, '-b', "$sftpfile","$esxbackupserver";
i am sure it will works.