Need help with really elementary pexpect fragment

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Need help with really elementary pexpect fragment

Saqib Ali

I want to write a pexpect script that simply cd's into a directory ("~/
install") and then runs a command from there. It should be so easy.
But even my cd command is failing. Can't figure out what the problem
is. The command line prompt is "[my machine name here] % "

Here is the code fragment:

    print "Spawning Expect"
    p = pexpect.spawn ('/bin/tcsh',)

    print "Sending cd command"
    i = p.expect([pexpect.TIMEOUT, "%",])
    assert i != 0, "Time-Out.... exiting"
    p.sendline("cd ~/install")

Here is the output:

Spawning Expect
Sending cd command
Time-Out.... exiting


How could I be screwing something so simple up??
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: Need help with really elementary pexpect fragment

Nick Dokos
Saqib Ali <[hidden email]> wrote:

>
> I want to write a pexpect script that simply cd's into a directory ("~/
> install") and then runs a command from there. It should be so easy.
> But even my cd command is failing. Can't figure out what the problem
> is. The command line prompt is "[my machine name here] % "
>
> Here is the code fragment:
>
>     print "Spawning Expect"
>     p = pexpect.spawn ('/bin/tcsh',)
>

If you execute /bin/tcsh by hand, do you get a "%" prompt?

Nick

>     print "Sending cd command"
>     i = p.expect([pexpect.TIMEOUT, "%",])
>     assert i != 0, "Time-Out.... exiting"
>     p.sendline("cd ~/install")
>
> Here is the output:
>
> Spawning Expect
> Sending cd command
> Time-Out.... exiting
>
>
> How could I be screwing something so simple up??
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: Need help with really elementary pexpect fragment

Saqib Ali
Oops! Good call. 
Thank you. You pointed out my mistake.


- Saqib




On Tue, Dec 20, 2011 at 12:31 AM, Nick Dokos <[hidden email]> wrote:
Saqib Ali <[hidden email]> wrote:

>
> I want to write a pexpect script that simply cd's into a directory ("~/
> install") and then runs a command from there. It should be so easy.
> But even my cd command is failing. Can't figure out what the problem
> is. The command line prompt is "[my machine name here] % "
>
> Here is the code fragment:
>
>     print "Spawning Expect"
>     p = pexpect.spawn ('/bin/tcsh',)
>

If you execute /bin/tcsh by hand, do you get a "%" prompt?

Nick

>     print "Sending cd command"
>     i = p.expect([pexpect.TIMEOUT, "%",])
>     assert i != 0, "Time-Out.... exiting"
>     p.sendline("cd ~/install")
>
> Here is the output:
>
> Spawning Expect
> Sending cd command
> Time-Out.... exiting
>
>
> How could I be screwing something so simple up??
> --
> http://mail.python.org/mailman/listinfo/python-list
>


--
http://mail.python.org/mailman/listinfo/python-list