how to push data in to ssh in python?

Thomas Wouters thomas at xs4all.net
Tue Jul 4 02:34:59 EDT 2000


On Tue, Jul 04, 2000 at 09:51:03AM +1000, Sam Wun wrote:
> Thomas Wouters wrote:
> 
> > On Mon, 03 Jul 2000 11:56:41 +1000, Sam Wun <swun at esec.com.au> wrote:
> >
> > >Thanks
> >
> > Your question is incomplete. What do you want to do ? Did you look at
> > popen(), and is it not what you want ? Does ssh require the input to
> > come from a pseudo-terminal ? Can't you use a normal shell pipeline and
> > make your python script just 'print' what you want to output ? Are you
> > encountering difficulties with any of these ideas, or not finding the
> > right documentation?

> Oh yes, I actually print it to the stdout, and intended to use command
> "ssh -l swun hostname < out.dump" to send out.dump to the "hostname" in
> "swun" account, but I am not sure how to set up the "swun" account to
> receive this transaction.

'ssh' is 'secure shell'. If you give it no additional arguments, it spawns a
new shell for you, on the remote machine. If you do give it more, it'll
start that as a program on the remote machine. So, if you want ssh on the
remote machine to dump the output to a file, you can probably do

ssh -l login machine "cat > outfile.dump"

or some such. The quotes are necessary, by the way, to make sure the '>'
redirection is passed to ssh, not interpreted by your shell. But if you
intend to cat a local file, why not scp the file instead ?

scp outfile.dump login at machine:

Your question is more of 'how do I use ssh' than 'how do I use python' ;)

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list