[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-date: Mon Nov 22 17:35:40 2004 -->
- <!--x-from-r13: nyrqbaar ng lnubb.pbz (Oyrk ZrRbaar) -->
- <!--x-message-id: [email protected] -->
- <!--x-subject: [ale] Python & pexpect problem -->
- <li><em>date</em>: Mon Nov 22 17:35:40 2004</li>
- <li><em>from</em>: aledonne at yahoo.com (Alex LeDonne)</li>
- <li><em>subject</em>: [ale] Python & pexpect problem</li>
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>
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00943" href="msg00943.html">[ale] Python & pexpect problem</a></strong>
<ul><li><em>From:</em> jloden at toughguy.net (Jay Loden)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00937.html">[ale] cron mail messages</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00939.html">[ale] Michael Millard is out of the office until Nov. 22</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00950.html">[ale] Python & pexpect problem</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00943.html">[ale] Python & pexpect problem</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00938"><strong>Date</strong></a></li>
<li><a href="threads.html#00938"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>