[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Mon Nov 22 18:34:59 2004 -->
- <!--x-from-r13: wybqra ng gbhtuthl.arg (Xnl Zbqra) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] Python & pexpect problem -->
- <li><em>date</em>: Mon Nov 22 18:34:59 2004</li>
- <li><em>from</em>: jloden at toughguy.net (Jay Loden)</li>
- <li><em>in-reply-to</em>: <<a href="msg00938.html">[email protected]</a>></li>
- <li><em>references</em>: <<a href="msg00938.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] Python & pexpect problem</li>
-Jay
On Monday 22 November 2004 05:34 pm, Alex LeDonne wrote:
> Jay-
>
> I suspect the problem is that the command you give to spawn() doesn't
> go through a shell, so the * file glob doesn't work - it's just a
> literal splat character.
>
> I think for the "else" case, you'll to build the list of the files in
> python, so the command you spawn ends up looking like
>
> scp file1.htm file2.htm file3.htm ... scp_to
>
>
> -Alex
>
> > From: Jay Loden <jloden at toughguy.net>
> > Subject: [ale] Python & pexpect problem
> > To: Atlanta Linux Enthusiasts <ale at ale.org>
> >
> > I have a script that I'm trying to use to do a backup of my website
> > to my home machine using scp. It uses pexpect to enter the password
> > for scp, and it's supposed to get all the .htm and .jpg files from
> > /var/www/html/ and download them to my desktop machine.
> >
> > However, when I run the script, all I get is an error saying
> > "/var/www/html/*.htm" : file does not exist
> >
> > Oddly, if I run the command the usual way from a prompt, it works
> > fine (i.e. scp /var/www/html/*.htm
> > jay at desktop.jayloden.com:/home/jay/)
>
> [snipped all but the relevant function]
>
> > def scp(path, scp_to = """
> > jay at desktop.jayloden.com:/home/jay/www/jayloden/html/"""):
> > '''does the actual scp work'''
> > password = "password"
> > command = "scp " + path + scp_to
> > recurse_cmd = "scp -r " + path + scp_to
> >
> > if os.path.isdir(path):
> > child = pexpect.spawn(recurse_cmd)
> > child.expect('password:')
> > child.sendline(password)
> > child.expect(pexpect.EOF)
> >
> > print child.before
> >
> > else:
> > child = pexpect.spawn(command)
> > child.expect('password:')
> > child.sendline(password)
> > child.expect(pexpect.EOF)
> >
> > print child.before
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> <a rel="nofollow" href="http://mail.yahoo.com">http://mail.yahoo.com</a>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> <a rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale">http://www.ale.org/mailman/listinfo/ale</a>
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00938" href="msg00938.html">[ale] Python & pexpect problem</a></strong>
<ul><li><em>From:</em> aledonne at yahoo.com (Alex LeDonne)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00942.html">[ale] Sort of OT: College Majors</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00944.html">[ale] multiple network setups (wireless)?</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00938.html">[ale] Python & pexpect problem</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00918.html">[ale] VNC dieing and killing session</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00943"><strong>Date</strong></a></li>
<li><a href="threads.html#00943"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>