OS system calls from bash script

Is it possible to call os system calls like open, close etc from a shell script? I tried searching on Google, but I was not able to use the system () command. Can anyone help with this?

+5
source share
1 answer

Many system calls are available, but only through their own shell mechanisms, and cannot directly specify the exact parameters. For instance:

exec 4>outfile

calls:

open("outfile", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3
dup2(3, 4)

(when replacing 3with the next available descriptor) and

exec 4<&-

calls:

close(4)

, bash, (. enable, ); , , .

+5

All Articles