Continuous system call problem

Ok, I got system calls working fine, but can anyone answer this?? I have an if/else statement that it always goes in the if currently. In the if there is a function that gets run and then I will need to make a system call after that function. Unfortunately, I cannot post my code because my job wouldn’t like that and it’s over 1000 lines anyway…but here is a small example

if (condition)
{
Some_Function();
system("./foo");
}
else (condition)
{

}

Pretty simple, and I don’t see the problem…foo is the script which contains:

#!/bin/sh

touch foobar


So the problem is that it does not create this file “foobar”
However, if i do system(“touch foobar”); it works in its place…why would a system call work there for a function and not a script

PS. the system call for the script works if i call it in the beginning…go figure

And the permissions and paths seem to be right…anyone know why this could all be???

I have a few idea what could be going on. I won`t share them until you confirm you have added code to check the return value of system() and report that value and the value of errno,

system() returns 0, errno is 2.

Well it still wouldn’t work, so instead of a simple system call on QNX’s end, we are doing a scheduled batch file from the Windows end (where we are FTP-ing to)…