in reply to how do i run a shell command without waiting for the output
is this rigth ?
Yes - if, as your code shows, you are using exec. You can use system as well inside the forked process, which allows you to check the return code; you have to exit after that. But you can also do without the fork, since system does an implicit fork, and spawn the process via /bin/sh in the background:
system qq(curl -H "Content-Type: application/json" -X POST -d '$datacu +rl' http://192.168.125.169/index.php/itsqd/v1/nmessage &); # <--- not +ice the ampersand
This lets you check - again, via the return code, which should be 0 on success - whether the shell succeeded spawning curl. If so, the shell returns immediately, and the curl process runs in the background. Otherwise the shell exits with a non-zero value, which is returned by system.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: how do i run a shell command without waiting for the output
by afoken (Chancellor) on Apr 25, 2017 at 18:09 UTC | |
by shmem (Chancellor) on Apr 25, 2017 at 19:03 UTC |