Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   How do I separate my parameters with spawnv (http://www.velocityreviews.com/forums/t396665-how-do-i-separate-my-parameters-with-spawnv.html)

Fabio Chelly 11-23-2006 10:56 AM

How do I separate my parameters with spawnv
 
Hi,

I have a command line that works fine when I execute it directly:

c:\\curl.exe -T c:\\upload.txt -u login:pwd ftp://ftp-myurl --ftp-ssl

But when I try to use os.spawnv to excute it from my python code, it
doesn't work at all. Here is my code:

exe = "c:\\curl.exe"
f = "c:\\upload.txt"
logon = "login:pwd"
url = "ftp://ftp-myurl"
import os
os.spawnv(os.P_WAIT, exe, ["-T", f, "-u", logon, url, "--ftp-ssl"])

Does anyone know How I can execute my command line in python?

Thanks and best regards,
Fabio

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net



Fredrik Lundh 11-23-2006 11:05 AM

Re: How do I separate my parameters with spawnv
 
Fabio Chelly wrote:

> But when I try to use os.spawnv to excute it from my python code, it
> doesn't work at all. Here is my code:
>
> exe = "c:\\curl.exe"
> f = "c:\\upload.txt"
> logon = "login:pwd"
> url = "ftp://ftp-myurl"
> import os
> os.spawnv(os.P_WAIT, exe, ["-T", f, "-u", logon, url, "--ftp-ssl"])


iirc, spawnv expects an argv-style list, with the program name as the
first argument. try writing the above as

os.spawnv(os.P_WAIT, exe, [exe, "-T", f, "-u", logon, url, "--ftp-ssl"])

> Does anyone know How I can execute my command line in python?


the subprocess module is usually much nicer for things like this.

</F>


Fabio Chelly 11-23-2006 02:06 PM

Re: How do I separate my parameters with spawnv
 
Thank you very much

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net




All times are GMT. The time now is 12:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.