bash の代わりに ash を使用して組み込みシステムに取り組んでおり、クロスコンパイルされた C プログラムからスクリプトを呼び出そうとしています。
それは機能していますが、私が求めているようなバックグラウンド プロセスではありません。実際、strcat コマンドが機能していないように見えますが、その理由はわかりません。
私はCでかなり新しいので、それは明らかなものでなければなりません。
コード:
char mycall[230] = "/home/root/myscript.sh ";
char inbackground[3]= " &";
// buf is initiated and will be used as a parameter, string length is about 20 characters
strcat(buf,inbackground);
strcat(mycall,buf);
printf("%s", mycall); // this will display the command and parameter that was stored with
// in buf correctly, but without the ampersand at the end
system(mycall); // executes correctly
画面表示:
sh: syntax error: "&" unexpected
なぜこれを行うのですか?