I have a pretty easy problem I'm trying to resolve here. I'm constantly running the (host) command on domains, to get their IPs, then (host) again on those IPs to get their PTRs, then I'm SSHing to that server represented in the PTR:

[root@box ~]$ host DomainIWant.com
DomainIWant.com has address

[root@box ~]$ host domain name pointer vps2010.DomainIWantHosts.com

[root@box ~]$ ssh vps2010.DomainIWantHosts.com

Simple enough right? It's just tedious doing this over and over, so as with everything Linux I want to speed it up by automating it:

[root@box ~]$ host DomainIWant.com | awk '{print $4}' | xargs host | awk '{print $5}' | xargs ssh -tt

The problem that I'm having is when I call ssh via xargs, I do get SSH'd into the remote server but with the error [tcgetattr: Invalid argument]. I'm sitting at the remote server's shell but when I try to run any command it just hangs and eventually I have to Ctrl-C to break out of it.

If I don't tack on the (ssh -tt) then I get a [Pseudo-terminal will not be allocated because stdin is not a terminal] error. This seems like such a simply problem so I'm hoping someone more familiar with ssh via xargs can let me know if it's even possible.

  • Are you getting into the server using ssh? If so, this should not be the problem of the command you presented above.
    – Khaled
    Commented Nov 27, 2010 at 15:14
  • Yes I'm SSHing into a box inside a network, then using that box to jump to other ones on the same network. Using the above commands both lead to the 2nd server I'm connecting to not allowing me to type in any input.
    – JacobN
    Commented Dec 2, 2010 at 3:20

1 Answer 1


If you're using a shell that supports backticks- or $()-style command substitution (most shells do), then in your case, you can avoid using xargs entirely, like this:

ssh $(host -t PTR $(host -t A DomainIWant.com | awk '{print $4}') | awk '{print $5}')

(I added the -t flags to the host commands, to ensure they only emit 1 line of output.)

  • Thanks! This worked just as I wanted, nice to see I can bypass xargs all together. That's why I love Linux always more than one way to accomplish something.
    – JacobN
    Commented Dec 2, 2010 at 3:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .