executing unix command on a diff domain

Discussion in 'Perl Misc' started by Slickuser, Dec 9, 2008.

  1. Slickuser

    Slickuser Guest

    $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
     
    Slickuser, Dec 9, 2008
    #1
    1. Advertising

  2. Slickuser

    Teo Guest

    On Dec 9, 7:34 am, Slickuser <> wrote:
    > $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


    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
     
    Teo, Dec 9, 2008
    #2
    1. Advertising

  3. Slickuser

    Slickuser Guest

    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 <> wrote:
    > On Dec 9, 7:34 am, Slickuser <> wrote:
    >
    > > $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

    >
    > 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
     
    Slickuser, Dec 9, 2008
    #3
  4. Slickuser

    Slickuser Guest

    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 <> 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
     
    Slickuser, Dec 10, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cyril Vi?ville

    diff Process under diff users

    Cyril Vi?ville, Jun 29, 2004, in forum: Perl
    Replies:
    1
    Views:
    523
    Joe Smith
    Jun 29, 2004
  2. Berrucho
    Replies:
    2
    Views:
    668
    Infant Newbie
    Dec 5, 2003
  3. A Traveler

    Diff CSS styles for diff INPUT TYPE='s?

    A Traveler, Aug 31, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,958
    Steve Fulton
    Aug 31, 2004
  4. TonyHa

    Unix diff command under Window.

    TonyHa, Aug 24, 2005, in forum: Python
    Replies:
    8
    Views:
    4,019
    Thomas Heller
    Aug 25, 2005
  5. Austin Ziegler

    [ANN] Diff::LCS 1.1.0, Diff::LCS 1.0.4

    Austin Ziegler, Aug 8, 2004, in forum: Ruby
    Replies:
    3
    Views:
    207
    Austin Ziegler
    Aug 9, 2004
Loading...

Share This Page