dos programming question

Status
Not open for further replies.

y0da

Wise, Aged Ars Veteran
127
k really simple question here
why does this code not work in dos?
system("ping yahoo.com > temp.txt");
it will compile but gives me the error Bad parameter >

oddly enough though
a)ping yahoo.com > temp.txt
works fine from the dos console

b) system("ping yahoo.com");
works fine from my program

so anyone have any idea what on earth is wrong here?
Oh and btw all im trying to do is pipe the output of ping yahoo.com into temp.txt
argh... so annoying... anyone know?
 

dereferenced

Ars Scholae Palatinae
706
What compiler are you using and under what operating system are you running your program? I tried Turbo C++ 1.01 (a 16-bit DOS compiler), Borland C++ 5.5.1, MSVC.NET Version 13.00.9466, and cygwin gcc 2.9.5 and under Windows 2000 all of them worked. It's either a library implementation issue or an issue with the command interpreter/operating system. Have you tried

system("command.com /c ping yahoo.com > temp.txt");

or

system("cmd.exe /c ping yahoo.com > temp.txt");

under NT/2000/XP.
 
Status
Not open for further replies.