[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 08:59:41 2004 -->
- <!--x-from-r13: wybqra ng gbhtuthl.arg (Xnl Zbqra) -->
- <!--x-message-id: [email protected] -->
- <!--x-subject: [ale] Python & pexpect problem -->
- <li><em>date</em>: Mon Nov 22 08:59:41 2004</li>
- <li><em>from</em>: jloden at toughguy.net (Jay Loden)</li>
- <li><em>subject</em>: [ale] Python & pexpect problem</li>
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/)
I'm somewhat stumped since Python is a new thing for me and this is just one
of a few scripts to cut my teeth on. Thanks for the help.
-Jay
The script is below:
#! /usr/bin/env python
import os
import sys
import pexpect
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
def main():
scp("""/html/*.htm""")
scp("""/html/*.jpg""",
""" jay at desktop.jayloden.com:/home/jay/www/jayloden/img/""")
main()
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00950" href="msg00950.html">[ale] Python & pexpect problem</a></strong>
<ul><li><em>From:</em> fletch at phydeaux.org (Fletch)</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="msg00909.html">[ale] Michael Millard is out of the office until Nov. 22</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00911.html">[ale] Michael Millard is out of the office until Nov. 22</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00902.html">[ale] iptables question</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00950.html">[ale] Python & pexpect problem</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00910"><strong>Date</strong></a></li>
<li><a href="threads.html#00910"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>