Trying to use Net::SSH::Expect

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tprizler
    New Member
    • Jul 2008
    • 2

    #1

    Trying to use Net::SSH::Expect

    Hi,

    I am trying to use Net::SSH::Expec t.

    Basically I had success login into a remote server using this module.

    The thing is i think i have a syntax problem...

    I am logging into a remote server using ssh and trying to edit a file so this is waht i do:
    Code:
    $ssh->exec("sed 's/\/user/\#\/user/' /etc/auto.master > /etc/auto.master.new");
    $ssh->exec("rm -fr /etc/auto.master");
    $ssh->exec("mv /etc/auto.master.new /etc/auto.master");
    for some reason the first line (sed) fails, and i don't know why,,,


    Any one has an idea??

    Thanks!
    Last edited by numberwhun; Jul 16 '08, 03:33 PM. Reason: Please use code tags
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    On the remote machine, have you tried executing that sed command to ensure that it works as expected and isn't throwing any errors?

    Also, what does it say when it fails?


    Regards,

    Jeff

    Comment

    • tprizler
      New Member
      • Jul 2008
      • 2

      #3
      Hi,

      Yes of course I tried it, and it worked.

      Any way the code had to be modified into this :

      $ssh->exec("sed 's,/user,#\/user,' /etc/auto.master > /etc/auto.master.new ");

      Now it works.

      Comment

      • jazza234
        New Member
        • Jul 2008
        • 1

        #4
        It's possible that you need to enable raw_pty in the login block. The author's release notes on cpan mentions that it sometimes resolves pty compatability issues. I'm still trying to figure it out myself, though. If I could just figure out a way to increase the login timeout interval! Good luck.

        -Justin

        Comment

        Working...