system (cmd) on windows

  • Thread starter Rebhan, Gilbert
  • Start date
R

Rebhan, Gilbert

Hi,

two questions :

1.

system("T:/cvsnt/cvs.exe", "-d
:pserver:username@cvshost:d:/cvsrepos/test co Foobar")
doesn't work, whereas
system("T:/cvsnt/cvs.exe -d :pserver:username@cvshost:d:/cvsrepos/test
co Foobar")
works

all examples i found had system ("cmd", "args")
is that normal for some executables or is it a buggy behaviour from
cvs.exe ?


2.

my rubyscript lies under C:/cvs.rb
my cvsworkspace =3D T:/cvsworkspace

now i want to fire my cvs command out of the=20
cvsworkspace folder

in a windowshell i would do=3D
T:
cd workspace
T:/cvsnt/cvs.exe -d :pserver:username@cvshost:d:/cvsrepos/test co Foobar

how to emulate that with system(...)
i tried to ; separate it :

system("T:;cd workspace;T:/cvsnt/cvs.exe -d
:pserver:username@cvshost:d:/cvsrepos/test co Foobar")

but that doesn't work

Any ideas ?



Regards, Gilbert
 
B

Brian Candler

1.

system("T:/cvsnt/cvs.exe", "-d
:pserver:username@cvshost:d:/cvsrepos/test co Foobar")
doesn't work, whereas
system("T:/cvsnt/cvs.exe -d :pserver:username@cvshost:d:/cvsrepos/test
co Foobar")
works

all examples i found had system ("cmd", "args")
is that normal for some executables or is it a buggy behaviour from
cvs.exe ?

No, you have to go entirely one way or the other. That is, either split out
all the arguments yourself:

system("T:/cvsnt/cvs.exe", "-d", ":pserver:username@cvshost:d:/cvsrepos/test", "co", "Foobar")

Or pass a single string, as in your second example, in which case the shell
will be used to split them.

Passing separate arguments is safer against certain forms of attack, and
makes it easy to pass arguments which themselves contains spaces or other
shell metacharacters.
my rubyscript lies under C:/cvs.rb
my cvsworkspace = T:/cvsworkspace

now i want to fire my cvs command out of the
cvsworkspace folder

in a windowshell i would do=
T:
cd workspace
T:/cvsnt/cvs.exe -d :pserver:username@cvshost:d:/cvsrepos/test co Foobar

how to emulate that with system(...)
i tried to ; separate it :

system("T:;cd workspace;T:/cvsnt/cvs.exe -d
:pserver:username@cvshost:d:/cvsrepos/test co Foobar")

but that doesn't work

What error does it give? Perhaps you just need
system("T:;cd \\workspace; ..."

This won't work with the argument-split example given above. In that case
you could do it from Ruby, e.g.
Dir.chdir("...wherever...") do
system("...whatever..")
end

HTH,

Brian.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,940
Messages
2,570,107
Members
46,573
Latest member
new_ojitomagico

Latest Threads

Top