mwilliamson / spur.py

Run commands and manipulate files locally or over SSH using the same interface
BSD 2-Clause "Simplified" License
267 stars 37 forks source link

Unable to run multiple commands with pipe #28

Closed pandel closed 9 years ago

pandel commented 9 years ago

I'm trying to form complexer commands by concatenating them via pipe symbol and execute them through SshShell.

Commands look like this, i.e.:

atq -q D | cut -f1 | xargs at -q D -c | grep user

I tried to construct a command list for SshShell but nothing seems to work. Isn't it possible at the moment to concat commands via piping?

mwilliamson commented 9 years ago

What code are you actually using to run the command? Commands are run directly, rather than through a shell, so if you want to use pipes, then you'll need to run an appropriate shell command e.g.

shell.run(["sh", "-c", "atq -q D | cut -f1 | xargs at -q D -c | grep user"])

pandel commented 9 years ago

Yes, your example is one of the variations I tried. After a lot more research I found out, that the command itself is transmitted correctly. But many many thanks for your answer. It made clear how to do it correctly.

mwilliamson commented 9 years ago

Glad to hear you got it sorted.