Can anyone tell me why this would cause "Invalid Number of Parameters" while
trying to compile (or interpret or whatever)
import os
os.execl("C:/WINDOWS/system32/xcopy.exe","E:/MainWeb/dreampics/*.*","E:/Main
Web/dp")
Here's what the Python reference says:
execl(path,arg0 , arg1, ...)
if you can see something obvious, please tell me
thanks
Steve 9 3021
On Sun, 14 Dec 2003 20:53:10 GMT, "python newbie" <me*******@hotm ail.com> wrote: Can anyone tell me why this would cause "Invalid Number of Parameters" while trying to compile (or interpret or whatever)
import os os.execl("C:/WINDOWS/system32/xcopy.exe","E:/MainWeb/dreampics/*.*","E:/Main Web/dp")
Here's what the Python reference says: execl(path,arg0 , arg1, ...)
if you can see something obvious, please tell me
I think xcopy uses suffixed optional forward-slash switch options, so it might be getting confused?
I'd try (note the 'r' prefixes for raw string literals):
os.execl(r"C:\W INDOWS\system32 \xcopy.exe", r"E:\MainWeb\dr eampics\*.*", r"E:\MainWeb\dp ")
I don't know what the length or count limits might be on expansion of "*.*" but hopefully
it it pretty big.
Regards,
Bengt Richter
I tried that and it didn't work, but I like the direction you suggested.
Thanks, I'll figure this sucker out.
"Bengt Richter" <bo**@oz.net> wrote in message
news:br******** **@216.39.172.1 22... On Sun, 14 Dec 2003 20:53:10 GMT, "python newbie" <me*******@hotm ail.com>
wrote:Can anyone tell me why this would cause "Invalid Number of Parameters"
whiletrying to compile (or interpret or whatever)
import os os.execl("C:/WINDOWS/system32/xcopy.exe","E:/MainWeb/dreampics/*.*","E:/Mai
nWeb/dp")
Here's what the Python reference says: execl(path,arg0 , arg1, ...)
if you can see something obvious, please tell me
I think xcopy uses suffixed optional forward-slash switch options, so it
might be getting confused? I'd try (note the 'r' prefixes for raw string literals):
os.execl(r"C:\W INDOWS\system32 \xcopy.exe",
r"E:\MainWeb\dr eampics\*.*", r"E:\MainWeb\dp ") I don't know what the length or count limits might be on expansion of
"*.*" but hopefully it it pretty big.
Regards, Bengt Richter
"python newbie" wrote: Can anyone tell me why this would cause "Invalid Number of Parameters" while trying to compile (or interpret or whatever)
import os os.execl("C:/WINDOWS/system32/xcopy.exe","E:/MainWeb/dreampics/*.*","E:/Main Web/dp")
Here's what the Python reference says: execl(path,arg0 , arg1, ...)
first, fix the slashes. xcopy wants backward slashes in the filenames,
not forward slashes.
next, fix the number of arguments. at the top of the reference page
you refer to, there's a paragraph explaining how the exec arguments
work:
The various exec*() functions take a list of arguments for the
new program loaded into the process. In each case, the first
of these arguments is passed to the new program as its own
name rather than as an argument a user may have typed on
a command line. For the C programmer, this is the argv[0]
passed to a program's main(). For example, "os.execv('/bin/echo',
['foo', 'bar'])" will only print "bar" on standard output;
"foo" will seem to be ignored.
(from http://www.python.org/doc/current/lib/os-process.html )
in other words, you need to pass in the program name twice, to make
sure xcopy sees the filenames as argument 1 and 2.
(are you sure you want os.exec, btw? os.system or os.spawn* might
be a better choice...)
</F>
On Mon, 15 Dec 2003 00:18:32 +0100, "Fredrik Lundh" <fr*****@python ware.com> wrote: "python newbie" wrote:
Can anyone tell me why this would cause "Invalid Number of Parameters" while trying to compile (or interpret or whatever)
import os os.execl("C:/WINDOWS/system32/xcopy.exe","E:/MainWeb/dreampics/*.*","E:/Main Web/dp")
Here's what the Python reference says: execl(path,arg0 , arg1, ...) first, fix the slashes. xcopy wants backward slashes in the filenames, not forward slashes.
next, fix the number of arguments. at the top of the reference page you refer to, there's a paragraph explaining how the exec arguments work:
The various exec*() functions take a list of arguments for the new program loaded into the process. In each case, the first of these arguments is passed to the new program as its own name rather than as an argument a user may have typed on a command line. For the C programmer, this is the argv[0] passed to a program's main(). For example, "os.execv('/bin/echo', ['foo', 'bar'])" will only print "bar" on standard output; "foo" will seem to be ignored.
(from http://www.python.org/doc/current/lib/os-process.html )
in other words, you need to pass in the program name twice, to make sure xcopy sees the filenames as argument 1 and 2.
Hmph, I missed that, in spite of the fact that I execl'd my C++ args printer:
Like OP's xcopy execl: os.execl(r'c:\u til\pargs.exe', '1', '2', '3')
argc = 3
argv[0] = "1"
argv[1] = "2"
argv[2] = "3"
from command line, arg[0] gets inserted:
[16:35] C:\pywk\clp>c:\ util\pargs.exe 1 2 3
argc = 4
argv[0] = "c:\util\pargs. exe"
argv[1] = "1"
argv[2] = "2"
argv[3] = "3"
where
[16:58] E:\VCWK\test\t3 >type pargs.cpp
#include <stdio.h>
int main(const int argc,const char *argv[]){
printf("argc = %2d\n",argc);
for(int i=0;i<argc;i++) {
printf("argv[%d] = \"%s\"\n",i,arg v[i]);
}
return 0;
}
Too hurried. Anyway, the above illustrates what you point out.
(are you sure you want os.exec, btw? os.system or os.spawn* might be a better choice...)
Seems like.
Regards,
Bengt Richter
Since you both agree, I'll try spawn. thanks for the help and the insight.
As Paul Harvey would say, good day ( or evening)
"Fredrik Lundh" <fr*****@python ware.com> wrote in message
news:ma******** *************** **************@ python.org... "python newbie" wrote:
Can anyone tell me why this would cause "Invalid Number of Parameters"
while trying to compile (or interpret or whatever)
import os
os.execl("C:/WINDOWS/system32/xcopy.exe","E:/MainWeb/dreampics/*.*","E:/Main Web/dp")
Here's what the Python reference says: execl(path,arg0 , arg1, ...)
first, fix the slashes. xcopy wants backward slashes in the filenames, not forward slashes.
next, fix the number of arguments. at the top of the reference page you refer to, there's a paragraph explaining how the exec arguments work:
The various exec*() functions take a list of arguments for the new program loaded into the process. In each case, the first of these arguments is passed to the new program as its own name rather than as an argument a user may have typed on a command line. For the C programmer, this is the argv[0] passed to a program's main(). For example, "os.execv('/bin/echo', ['foo', 'bar'])" will only print "bar" on standard output; "foo" will seem to be ignored.
(from http://www.python.org/doc/current/lib/os-process.html )
in other words, you need to pass in the program name twice, to make sure xcopy sees the filenames as argument 1 and 2.
(are you sure you want os.exec, btw? os.system or os.spawn* might be a better choice...)
</F>
Fredrik Lundh wrote: "python newbie" wrote: Can anyone tell me why this would cause "Invalid Number of Parameters" while trying to compile (or interpret or whatever)
import os os.execl("C:/WINDOWS/system32/xcopy.exe","E:/MainWeb/dreampics/*.*","E:/Main Web/dp")
Here's what the Python reference says: execl(path,arg0 , arg1, ...)
(are you sure you want os.exec, btw? os.system or os.spawn* might be a better choice...)
Or shutil.copytree ?
Gerrit.
--
166. If a man take wives for his son, but take no wife for his minor
son, and if then he die: if the sons divide the estate, they shall set
aside besides his portion the money for the "purchase price" for the minor
brother who had taken no wife as yet, and secure a wife for him.
-- 1780 BC, Hammurabi, Code of Law
--
Asperger's Syndrome - a personal approach: http://people.nl.linux.org/~gerrit/english/
You may try
os.execl("c:\\W INDOWS\system32 \xcopy.exe", "E:\\MainWeb\\d reampics\\*.*",
"E:\\MainWeb\\d p")
J.R.
"python newbie" <me*******@hotm ail.com> wrote in message
news:W4******** ***********@new ssvr29.news.pro digy.com... Can anyone tell me why this would cause "Invalid Number of Parameters"
while trying to compile (or interpret or whatever)
import os
os.execl("C:/WINDOWS/system32/xcopy.exe","E:/MainWeb/dreampics/*.*","E:/Main Web/dp")
Here's what the Python reference says: execl(path,arg0 , arg1, ...)
if you can see something obvious, please tell me thanks Steve
"J.R." <j.*****@motoro la.com> wrote: You may try os.execl("c:\\W INDOWS\system32 \xcopy.exe", "E:\\MainWeb\\d reampics\\*.*", "E:\\MainWeb\\d p")
that's a rather verbose way to get a compilation error:
ValueError: invalid \x escape
</F>
Sorry for the typo. The path delimiter on windows should be double
backslash, the
first one is for escape.
os.execl("c:\\W INDOWS\\system3 2\\xcopy.exe",
"E:\\MainWeb\\d reampics\\*.*", "E:\\MainWeb\\d p")
J.R.
"Fredrik Lundh" <fr*****@python ware.com> wrote in message
news:ma******** *************** **************@ python.org... "J.R." <j.*****@motoro la.com> wrote:
You may try os.execl("c:\\W INDOWS\system32 \xcopy.exe",
"E:\\MainWeb\\d reampics\\*.*", "E:\\MainWeb\\d p")
that's a rather verbose way to get a compilation error:
ValueError: invalid \x escape
</F> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chris Green |
last post by:
Hey folks,
I'm whipping up a quick CGI to wrap a command line app and I was a bit
suprised to not find a execl-like Popen3 style object. I don't want
to bother with the shell interpreting metacharaters by constructing a
command line.
Basically, I want something that acts just like Popen3 but allows me
to specify cmd as a path + args. Does something like this exist in
the standard library? If not, it sounds like a good candidate...
|
by: Erik Johnson |
last post by:
Hi,
I am trying to use Python to remap stdout and stderr to a log file for
an exec()'ed program.
The following code seems to work fine for the script itself, but my
expectation was that the exec'ed program would inherit its STDIN and STDOUT
and so would be printing to the log file also. Unfortunately, that is not
the case: the print statements in the spawned process come back to the
screen. So... I'm a little puzzled and am not finding...
|
by: PC |
last post by:
Is it possible to create pipe()s (stdin/stdout) for a child process
and forking a shell with execl() and controlling the shell's
stdin/stdout from the parent with select()?
Heres a little snippet of code. it doesnt actually work.. but it is
how I envisioned it::
if((n=accept(s,(struct sockaddr *)&remote,&sz))==-1)
{printf("accept\n"); exit(0);}
close(0); close(1); close(2);
pipe(&i);
|
by: shalombi |
last post by:
I am having a weird result with the execl() func under windows (i know
its meant for unix).
When I put the execl in a piece of code then run the app and when I
give a value to execl all it does is rerun the prog or rerun just
main() I dont know which.
Is this normal? Is it ok to use this if i want to loop my app?
I tried looking it up on google but didnt find anything.
This is actually pretty useful to me altough unusual.
Thanks
|
by: kisshug |
last post by:
i 'm working on a project in that i have 2 use 'execl' function can any
one give
how to use this function with 2 small programs in unix environment.
--
kisshug
Message posted via http://www.exforsys.com for all your training needs.
| |
by: Vijay |
last post by:
Dont study Linked List because I is quiet Difficult.
|
by: antoniosk |
last post by:
I have a problem calling a compiled program (for example hello.exe which stands for hello world) from another program (let's say time.exe) with execl function
/* program time.c */
#include <stdio.h>
#include <unistd.h>
main (int argc, char *argv)
{
|
by: vishalgupta |
last post by:
while working on vb we can work with acess and sql as backend but can we work with execl in backend ......is it efficient and easier to work with execl in backend or access in backend and why??
|
by: Sam |
last post by:
I have a program which works great when run from the command line.
But when I run it combined with something else such as:
- piping it through less
- cron
- execl (i.e. calling it from another python program)
it gives me a unicode error
File "../myparser.py", line 261, in set_attributes
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |