spawnl() and command.com

P

Pegboy

I am using Turbo C++ 3.0 for DOS. {I know... old tools.}

I am trying to execute "command.com /c ren file1.ext file2.ext" using
spawnl().

I am aware of rename() and system(), but I need to use command.com to do
this, if at all possible. Several have told me it is.

My attempts are all similar too:
i = spawnl( P_WAIT, "command.com", "command.com", "/c", "ren",
"file1.ext", "file2.ext", NULL );

The return value (i) is always -1, with errno indicating ENOENT or "No such
file or directory.".

I've have found many examples using spawnl(), however not with command.com,
and they all lead me to think I'm on the correct path. Can anybody help me
solve this situation?

I have even attempted something simple like "cls" rather the renaming... no
go.

Somebody said that I should also use getenv() to return the correct form of
command.com, but its not clear why or how.

Any help would be greatly appreciated. Thank you in advance.
 
J

Jack Klein

I am using Turbo C++ 3.0 for DOS. {I know... old tools.}

I am trying to execute "command.com /c ren file1.ext file2.ext" using
spawnl().

There is no standard C function spawnl(). It is a non-standard
extension.
I am aware of rename() and system(), but I need to use command.com to do
this, if at all possible. Several have told me it is.

I used rename() quite successfully on Borland 3.0 and 3.1, and have no
reason to doubt that they would not work.

Have you tried the very standard C library function system:

system("ren file1.exe file2.exe");

???

If you don't want to use system and want to stick to a non-standard
function like spawnl(), you'll need to ask in an MS-DOS programming
group line or one of Borlands's support
groups, most likely which requires
connecting to their news server nntp://newsgroups.borland.com.
Non-standard extensions are off-topic here.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
P

Pegboy

Yes, system() and rename() do work. I need to accomplish this as stated.
I will try your recommended groups. Thanks.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top