re-directing output stream

I have a spawnl function:

Child = spawnl (P_NOWAIT, “/bin/cp”, “cp”, “-vcLR”, “/source”,
“/destination”, NULL);
this works, it spawns a process to copy from /source to /destination

but I want to re-direct the output to a file called log.txt in my / diretory
so i added >>/log.txt :
Child = spawnl (P_NOWAIT, “/bin/cp”, “cp”, “-vcLR”, “/source”,
“/destination”, “>>/log.txt”, NULL);

now copy commands thinks >>/log.txt is the copy command’s destination.
any suggestion???

this commands works fine in a shell:
cp -vcLR /source /destination >>/log.txt

As you pointed out, redirection works in a shell. You are not spawning a shell.

ran zhang wrote:

I have a spawnl function:

Child = spawnl (P_NOWAIT, “/bin/cp”, “cp”, “-vcLR”, “/source”,
“/destination”, NULL);
this works, it spawns a process to copy from /source to /destination

but I want to re-direct the output to a file called log.txt in my / diretory
so i added >>/log.txt :
Child = spawnl (P_NOWAIT, “/bin/cp”, “cp”, “-vcLR”, “/source”,
“/destination”, “>>/log.txt”, NULL);

now copy commands thinks >>/log.txt is the copy command’s destination.
any suggestion???

this commands works fine in a shell:
cp -vcLR /source /destination >>/log.txt

is there a way to fix my spawnl function in order to re-direct my outputs to
a file???
Dean Douthat <ddouthat@faac.com> wrote in message
news:3BCC6EB7.2DCC08B0@faac.com

As you pointed out, redirection works in a shell. You are not spawning a
shell.

ran zhang wrote:

I have a spawnl function:

Child = spawnl (P_NOWAIT, “/bin/cp”, “cp”, “-vcLR”, “/source”,
“/destination”, NULL);
this works, it spawns a process to copy from /source to /destination

but I want to re-direct the output to a file called log.txt in my /
diretory
so i added >>/log.txt :
Child = spawnl (P_NOWAIT, “/bin/cp”, “cp”, “-vcLR”, “/source”,
“/destination”, “>>/log.txt”, NULL);

now copy commands thinks >>/log.txt is the copy command’s destination.
any suggestion???

this commands works fine in a shell:
cp -vcLR /source /destination >>/log.txt

You need to open the file (O_WRONLY | O_APPEND) getting file descriptor fd. Then
set iov[2] = fd in qnx_spawn_globs before spawnl. Be sure to reset iov[2] to 0xff
after spawnl.

This sounds alittle bit hard… would u provide me with some code .
how I get access to iov[2]…

Dean Douthat <ddouthat@faac.com> wrote in message
news:3BCC7269.4420367B@faac.com

You need to open the file (O_WRONLY | O_APPEND) getting file descriptor
fd. Then
set iov[2] = fd in qnx_spawn_globs before spawnl. Be sure to reset iov[2]
to 0xff
after spawnl.

Previously, ran zhang wrote in qdn.public.qnx4:

is there a way to fix my spawnl function in order to re-direct my outputs to
a file???

It’s not spawn*, but it’s quick and easy:
system(“cp -vcLR /source /destination >>/log.txt”);

Dean Douthat <> ddouthat@faac.com> > wrote in message
news:> 3BCC6EB7.2DCC08B0@faac.com> …
As you pointed out, redirection works in a shell. You are not spawning a
shell.

ran zhang wrote:

I have a spawnl function:

Child = spawnl (P_NOWAIT, “/bin/cp”, “cp”, “-vcLR”, “/source”,
“/destination”, NULL);
this works, it spawns a process to copy from /source to /destination

but I want to re-direct the output to a file called log.txt in my /
diretory
so i added >>/log.txt :
Child = spawnl (P_NOWAIT, “/bin/cp”, “cp”, “-vcLR”, “/source”,
“/destination”, “>>/log.txt”, NULL);

now copy commands thinks >>/log.txt is the copy command’s destination.
any suggestion???

this commands works fine in a shell:
cp -vcLR /source /destination >>/log.txt

\


-Jay.

Look up qnx_spawn_options under C library reference in helpviewer.

ran zhang wrote:

This sounds alittle bit hard… would u provide me with some code .
how I get access to iov[2]…

Dean Douthat <> ddouthat@faac.com> > wrote in message
news:> 3BCC7269.4420367B@faac.com> …
You need to open the file (O_WRONLY | O_APPEND) getting file descriptor
fd. Then
set iov[2] = fd in qnx_spawn_globs before spawnl. Be sure to reset iov[2]
to 0xff
after spawnl.