in reply to Re^9: Problem using Net::OpenSSH->capture to su to another user
in thread Problem using Net::OpenSSH->capture to su to another user

Hi Salva,

Ok, I've gotten it working now, the trick is to break up the command, surrounded by single quotes, so that su doesn't think it is being passed parameters.

However, I still always get the below error when the capture method is called.

tcgetattr: Invalid argument

I suppose it isn't a showstopper, but it makes the output of the script quite ugly with all these error lines coming through. I suppose there is no way of silencing this error?

regards,

Tim

  • Comment on Re^10: Problem using Net::OpenSSH->capture to su to another user

Replies are listed 'Best First'.
Re^11: Problem using Net::OpenSSH->capture to su to another user
by salva (Canon) on Jun 05, 2014 at 10:30 UTC
    Try also setting stderr_discard => 1 on the capture call.

      Hi Salva,

      Unfortunaytely that doesn't work. Note I also do something similar in the ssh constructor as in:

      my $ssh = Net::OpenSSH->new($master_host, user => "loguser", master_st +derr_discard => 1, expand_vars => => 1);

      Anything else I can try?

      Tim

        Both options are needed.

        Those errors are generated because you are requesting a TTY on the remote side but then there is no TTY on the local side and so when ssh tries to forward the ioctls, it gets that error back from the OS.

        Other than redirecting STDERR to /dev/null (which is what stderr_discard actually does) I don't see how that message can be suppresed.

        Use strace to see where are these msgs originate and where they go.

        Update: Updating the local OpenSSH may also help as new versions generate fewer of these useless warnings.