Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > executing unix command on a diff domain

Reply
Thread Tools

executing unix command on a diff domain

 
 
Slickuser
Guest
Posts: n/a
 
      12-09-2008

$command = "ssh ";
system($command);

$command2 = "ls /user/serv2/";
system($command2);

How do I get command 2 to work. I can get $command to work fine. thx

 
Reply With Quote
 
 
 
 
Teo
Guest
Posts: n/a
 
      12-09-2008
On Dec 9, 7:34*am, Slickuser <slick.us...@gmail.com> wrote:
> $command = "ssh x...@domain.com";
> system($command);
>
> $command2 = "ls /user/serv2/";
> system($command2);
>
> How do I get command 2 to work. I can get $command to work fine. thx


Hi,

if you want $command2 to be executed on the remote host you have to
send it as an argument of ssh:

my $command = 'ssh "ls /usr/serv2/"';
system $command;


Matteo
 
Reply With Quote
 
 
 
 
Slickuser
Guest
Posts: n/a
 
      12-09-2008
my $workstation = "xxx\@domain.com";
my $source_dir = "/aaa/bbb/ccc/ddd/"; #remote
my $destination_dir = "/xxx/yyy/zzz/"; #local

my $command1 = "rsync $source_dir $destination_dir";
my $command2 = "ssh $workstation $command1";

`$command2`;

How can I achieve that when my $source_dir on a remote server. I want
to rsync to destination which is not remote.

On Dec 8, 10:59*pm, Teo <matteo.co...@gmail.com> wrote:
> On Dec 9, 7:34*am, Slickuser <slick.us...@gmail.com> wrote:
>
> > $command = "ssh x...@domain.com";
> > system($command);

>
> > $command2 = "ls /user/serv2/";
> > system($command2);

>
> > How do I get command 2 to work. I can get $command to work fine. thx

>
> Hi,
>
> if you want $command2 to be executed on the remote host you have to
> send it as an argument of ssh:
>
> my $command = 'ssh u...@example.com "ls /usr/serv2/"';
> system $command;
>
> Matteo


 
Reply With Quote
 
Slickuser
Guest
Posts: n/a
 
      12-10-2008
Doesn't work if I have my configuration save in a .txt file.
Search for it, assign to variable and do a chomp on it.

$ws
$server /server/folder/a/b
$local /local/a/b/c


WORK:
my $cmd1 = "ssh $ws ls $server";
`$command_ssh`;

my @exec = "rsync -e ssh -avz user\@xxx.yyy.zzz.com:/server/folder/a/
b /local/a/b/c ";
print "@exec \n";
system(@exec);


DOESN'T WORK:
I think it has to do with @a in the user name & :. How can I fix this?
I have try qq, qw.

my @exec = "rsync -e ssh -avz $ws:$server $local ";
print "@exec \n";
system(@exec);


On Dec 9, 12:37*pm, Glenn Jackman <gle...@ncf.ca> wrote:
> At 2008-12-09 02:07PM, "Slickuser" wrote:
>
> > *my $workstation = "xxx\@domain.com";
> > *my $source_dir = "/aaa/bbb/ccc/ddd/"; #remote
> > *my $destination_dir = "/xxx/yyy/zzz/"; #local

>
> > *my $command1 = "rsync $source_dir $destination_dir";
> > *my $command2 = "ssh $workstation $command1";

>
> > *`$command2`;

>
> > *How can I achieve that when my $source_dir on a remote server. I want
> > *to rsync to destination which is not remote.

>
> You probably want:
>
> * * my @cmd = qw( rsync -e ssh remoteuser@remotehost:/remote/dir /local/dir );
> * * system(@cmd) == 0 or die "return value from system call: $?";
>
> --
> Glenn Jackman
> * * Write a wise saying and your name will live forever. -- Anonymous


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unix diff command under Window. TonyHa Python 8 08-25-2005 07:11 PM
diff Process under diff users Cyril Vi?ville Perl 1 06-29-2004 06:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57