Unix Programming - exec

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2005 > exec





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author exec
friend_05

2005-10-28, 4:53 pm

I am using exec in following way.

execl("/usr/bin/cksum","/usr/bin/cksum",rfile,(char*)NULL))


But I want to store the output in file. Like I can do on command line (
cksum filename > tempfile). How can I do this using exec.

Ertugrul Soeylemez

2005-10-28, 4:53 pm

Robert Harris

2005-10-28, 4:53 pm

friend_05 wrote:
> I am using exec in following way.
>
> execl("/usr/bin/cksum","/usr/bin/cksum",rfile,(char*)NULL))
>
>
> But I want to store the output in file. Like I can do on command line (
> cksum filename > tempfile). How can I do this using exec.
>

You need to use popen.
Mr. Uh Clem

2005-10-29, 5:51 pm

Robert Harris wrote:

> friend_05 wrote:
>
> You need to use popen.


In this case, is there any need to make a child??
Why not just:

tfd=open("tempfile"...);
if (tfd != -1)
{
if (tfd != 1)
{
dup2(tfd, 1);
close(tfd);
}
execl(....);
}
...error...







--
Clem
"If you push something hard enough, it will fall over."
- Fudd's first law of opposition
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com