rameshgsl has asked for the wisdom of the Perl Monks concerning the following question:

This following statement is not working. if i run the same code from cmd prompt then it is working fine.

system ("C:\\Program Files\\Wireshark\\tshark.exe " , "-i 3", "-c","10 +" ,"> c:\\ram.txt");

Replies are listed 'Best First'.
Re: System command is giving error if we redirect output to file
by cdarke (Prior) on Dec 10, 2008 at 12:39 UTC
    What does "not working" mean? What is the return value from system?

    I'm guessing that it is the  "-i 3" argument that is wrong; this should probably be two arguments, not a single one.
Re: System command is giving error if we redirect output to file
by roboticus (Chancellor) on Dec 10, 2008 at 12:41 UTC
    rameshgsl:

    Since we have to guess (you should have described what "not working" means in this case, along with any error messages you received). I'll guess that it's because tshark.exe isn't a shell and doesn't handle output redirection. If my guess is correct, then try executing a shell instead, and telling the shell to run tshark for you and redirect its output.

    ...roboticus
Re: System command is giving error if we redirect output to file
by Anonymous Monk on Dec 10, 2008 at 13:56 UTC
    the shell (cmd.exe or command.com on windows) is responsible for redirection, and you're not invoking the shell
      Thanks for your comments. Actually when I run the following command in command prompt working fine. tshark.exe -i 3 -c 10 > abcd.txt If I include the same command in system command as $status = system ("C:\\Program Files\\Wireshark\\tshark.exe " , "-i 3", "-c","10" ,"> c:\\ram.txt"); Error : Invalid capture filter: "> c:\ram.txt"