This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: System Calls
- From: "Murdoch, Matthew" <mmurdoch at PFC dot Forestry dot CA>
- To: "'cygwin at cygwin dot com'" <cygwin at cygwin dot com>
- Date: Wed, 7 Aug 2002 11:56:45 -0400
- Subject: Re: System Calls
I am trying to make a system call using the system function in C. I have an
executable program that requires at input text file and I want to put the
output in a text file. I cannot seem to get the system function to work.
I have tried the following:
system ("/cygdrive/c/users/mmurdoch/ACE/sixs \
< /cygdrive/c/users/mmurdoch/ACE/sixSIn.txt \
> /cygdrive/c/users/mmurdoch/ACE/sixSOut.txt")
and I have also tried
system("cmd /c c:\users\mmurdoch\ACE\sixs < c:\users\mmurdoch\ACE\sixSIn.txt
> c:\users\mmurdoch\ACE\sixSOut.txt);
- I have also tried it without the "cmd /c"
When I try to run either one the sixSOut.txt file is not produced. I am not
sure if the system command is working and simply
not piping the output to a text file or if is not working at all. When I
call my C program I do not get any errors and it seems to run okay.
I also have the same problem when I am trying to call the "ls" command. I
am trying to get a directory listing and store that listing in a text file.
I am trying to use the following command
system("ls c:\users\mmurdoch\ACE\
>c:\users\mmurdoch\ACE\dirlist.txt);
I have also tried adding the "command /c" at the beginning of the above
statement.
Any help would be appreciated.
Matthew Murdoch
Below is my previous message
> Hi list,
>
> I am fairly new to cygwin I have a fairly trivial question. I am trying
to
> make a system call using the system function in C. I have read some of
the
> previous postings on the newsgroup, but I am still stuck. I am trying to
> do the following command, which calls an executable file and supplies it
> with an input file. It then pipes the output to an otuput file.
>
> system("cmd /c c:\"users\"mmurdoch\"ACE\"sixs <
> c:\"users\"mmurdoch\"ACE\"sixSIn.txt
> > c:\"users\"mmurdoch\"ACE\"sixSOut.txt");
>
> I do have the "sh.exe" file in my \bin directory.
>
> Thanks in advance for the help
What exact error do you see? "I have a problem" isn't helpful
at all.
What are these \" ? Don't you mean \\ ?
Why are you running cmd to call the application? Why not call it
directly:
system ("/cygdrive/c/users/mmurdoch/ACE/sixs \
< /cygdrive/c/users/mmurdoch/ACE/sixSIn.txt \
> /cygdrive/c/users/mmurdoch/ACE/sixSOut.txt")
?
Or write a shell script and call that?
Corinna
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/