Why chdir command doesn't work with client.get_transport() ?
Charles_hans
charles_hans at yahoo.com
Tue Feb 5 14:39:23 EST 2008
Thank you, Matt, for your valuable advice! I did try using ';' to issue three
commands at once and it works!
However, I have more problems with issuing ClearCase commands, which is what
I am really doing.
Under telnet, I could issue commands one by one, just as typing at the
command prompt. Now I tried to use ';' manually typing two commands at once
on my Solaris command line, such as
ct setview viewName; cd dir_in_clearcase
(ct = cleartool) The second command will not be executed, since the command
prompt changes after the first command. --- I think that it was because
there was a long delay after the first command. (any way out?)
When I used exec_command() to do this in Python, even the first command was
not recognized (error: bad phone number. I used 'man ct' and found that ct
dials a phone number). Even if 'ct' was recognized, the second command would
not be executed. And it is useless to do it in the next exec_command()
function. (Without the first command, one can not cd into a directory in
ClearCase.)
Do you think that paramiko can replace telnet in my application? Thanks.
Charles
2/5
Matthew_WARREN wrote:
>
>
> As other have said, it's because exec_command uses a new session each
> time.
>
> You may get some joy with this, untested
>
> exec_command('cd /some/where; somecommand')
>
> uses the semi-colon to separate multiple commands on one command line.
>
>
> Matt.
>
>
>
>
>
> Internet
> charles_hans at yahoo.com
>
> To
>
> python-list
> Sent by:
> cc
> python-list-bounces+matthew.warren=uk.bnpparibas.com@
> python.org
> Subject
>
> Why chdir command doesn't work with
> 02/02/2008 23:41
> client.get_transport() ?
>
>
>
>
>
>
>
>
>
>
>
>
> I am new to paramiko. I wrote a script to copy files between Solaris and
> XP
> machines as below:
>
> import paramiko
> def exec_command(trans, command):
> chan = trans.open_session()
> chan.exec_command(command)
> stdin = chan.makefile('wb')
> stdout = chan.makefile('rb')
> stderr = chan.makefile_stderr('rb')
> return stdin, stdout, stderr
> def main():
> client = paramiko.SSHClient()
> client.connect(hostname, username=username, password=password)
> trans = client.get_transport()
> dummy_chan = trans.open_session()
> exec_command(trans, 'cd temp')
> stdin, stdout, stderr = exec_command(pwd)
>
>>From the last line I found from stdout that the pwd is not changed. I
> tried
> to type the full path in 'cd', did not help. Other UNIX commands such as
> ls,
> mkdir, cp, rm will work. Only this 'cd' never works. I got stuck here.
>
> Please help. Thanks!
>
> Charles
> 2/2
> --
> View this message in context:
> http://www.nabble.com/Why-chdir-command-doesn%27t-work-with-client.get_transport%28%29---tp15248798p15248798.html
>
> Sent from the Python - python-list mailing list archive at Nabble.com.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
>
> This message and any attachments (the "message") is
> intended solely for the addressees and is confidential.
> If you receive this message in error, please delete it and
> immediately notify the sender. Any use not in accord with
> its purpose, any dissemination or disclosure, either whole
> or partial, is prohibited except formal approval. The internet
> can not guarantee the integrity of this message.
> BNP PARIBAS (and its subsidiaries) shall (will) not
> therefore be liable for the message if modified.
> Do not print this message unless it is necessary,
> consider the environment.
>
> ---------------------------------------------
>
> Ce message et toutes les pieces jointes (ci-apres le
> "message") sont etablis a l'intention exclusive de ses
> destinataires et sont confidentiels. Si vous recevez ce
> message par erreur, merci de le detruire et d'en avertir
> immediatement l'expediteur. Toute utilisation de ce
> message non conforme a sa destination, toute diffusion
> ou toute publication, totale ou partielle, est interdite, sauf
> autorisation expresse. L'internet ne permettant pas
> d'assurer l'integrite de ce message, BNP PARIBAS (et ses
> filiales) decline(nt) toute responsabilite au titre de ce
> message, dans l'hypothese ou il aurait ete modifie.
> N'imprimez ce message que si necessaire,
> pensez a l'environnement.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
--
View this message in context: http://www.nabble.com/Why-chdir-command-doesn%27t-work-with-client.get_transport%28%29---tp15248798p15297822.html
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list
mailing list