Net::SSH::Perl - How to set remote default file permissions

Discussion in 'Perl Misc' started by Joe, Dec 13, 2007.

  1. Joe

    Joe Guest

    When I manually execute a script with Net::SSH::perl to run a remote
    program, the output file has a permission "660"; When I use a web
    server to execute the script (the script uses my user account identity/
    pass), the remote output file has a permission "600".

    How can I make the script to set a default remote file permission
    (like "644") so the web server can read the results back? I tried:
    ($stdout, $stderr, $exit) = $ssh->cmd("umask 022; script");
    and it didn't work.

    Thanks in advance!

    Joe
    Joe, Dec 13, 2007
    #1
    1. Advertising

  2. Joe

    Joe Guest

    On Dec 13, 12:53 pm, Joe <> wrote:
    > When I manually execute a script with Net::SSH::perl to run a remote
    > program, the output file has a permission "660"; When I use a web
    > server to execute the script (the script uses my user account identity/
    > pass), the remote output file has a permission "600".
    >
    > How can I make the script to set a default remote file permission
    > (like "644") so the web server can read the results back? I tried:
    > ($stdout, $stderr, $exit) = $ssh->cmd("umask 022; script");
    > and it didn't work.


    Well, a reply to myself - I accomplished this by
    ($stdout, $stderr, $exit) = $ssh->cmd("script; chmod 644 'outfile'");

    Joe
    Joe, Dec 14, 2007
    #2
    1. Advertising

  3. Joe

    J. Gleixner Guest

    Joe wrote:
    > On Dec 13, 12:53 pm, Joe <> wrote:
    >> When I manually execute a script with Net::SSH::perl to run a remote
    >> program, the output file has a permission "660"; When I use a web
    >> server to execute the script (the script uses my user account identity/
    >> pass), the remote output file has a permission "600".
    >>
    >> How can I make the script to set a default remote file permission
    >> (like "644") so the web server can read the results back? I tried:
    >> ($stdout, $stderr, $exit) = $ssh->cmd("umask 022; script");
    >> and it didn't work.

    >
    > Well, a reply to myself - I accomplished this by
    > ($stdout, $stderr, $exit) = $ssh->cmd("script; chmod 644 'outfile'");


    Probably better to have 'script' do the chomd, just in case 'outfile'
    ever changes within 'script'.
    J. Gleixner, Dec 14, 2007
    #3
    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. Tim Chandler
    Replies:
    0
    Views:
    210
    Tim Chandler
    Oct 7, 2003
  2. Tench Johnson
    Replies:
    1
    Views:
    290
    Biff Tannen
    Apr 23, 2010
  3. salamond

    net/ssh in ruby. ssh.exec fails

    salamond, Feb 17, 2011, in forum: Ruby
    Replies:
    0
    Views:
    240
    salamond
    Feb 17, 2011
  4. Replies:
    12
    Views:
    220
    Ch Lamprecht
    Sep 13, 2006
  5. Replies:
    0
    Views:
    96
Loading...

Share This Page