[Tutor] Sigh first real python task

Mike S mikeofmany at gmail.com
Thu Sep 13 05:06:06 CEST 2012


So, trying to modify a python script that when invoked copies a local file
to a remote host.

Previously this was done with only needing to pass a username.

<code>
    try:
        ret = subprocess.call("smbclient //metricsmachine/reports/; put
%s\" -U metrics%%" % (fileName), shell=True)
        if ret < 0:
                print >>sys.stderr, "Child was terminated by signal", -ret
        else:
            os.unlink(path+fileName)
    except OSError, e:
            print >>sys.stderr, "Execution failed:", e
<code>

Now, I'm having to change the remote host and pass both the username and
pass but cannot get it to work.

Changing it to

    try:
        ret = subprocess.call("smbclient //reportingmachine/Dashboard/; put
%s\" -U Username%Password" % (fileName), shell=True)
        if ret < 0:
                print >>sys.stderr, "Child was terminated by signal", -ret
        else:
            os.unlink(path+fileName)
    except OSError, e:
            print >>sys.stderr, "Execution failed:", e

Any help would be appreciated.

-- 
Mike of Many Stories, Ideas, and Ramblings
Game Chef 2009, 2010
NaNoWriMo 2008, 2009

http://mikeofmanystories.blogspot.com/ - writings
http://mikeofmany.wordpress.com/ - personal bloggery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120912/7f9853e4/attachment.html>


More information about the Tutor mailing list