fwriteを使用してphpから送信されたデータを読み取り、Linuxで文字列を出力するLinuxにacプログラムがあります。
AJAX
$.ajax({
type: "POST",
data: {cmd:"IN"},
url: "COMMAND.php",
success: function(data){
//Get only this string ">" from the stdout of linux and store it to a variable.
}
});
コマンド.php
<?php
if($_POST['cmd']=="IN"){
$fd = fopen("/tmp/myFIFO","w");
fwrite(fd,"IN");
fclose(fd);
}
?>
C
char buf[255];
while((n = read(fd, buf, sizeof buf - 1)) > 0 ){ //fd is the opened pipe.
buf[n - 1] = '\0';
if(strcmp(buf,"IN")==0){
printf("%s\n", "FF0023sff344>fdfslldlf");
}
}
Linux から ajax に文字列 "FF0023sff344>fdfslldlf" をキャプチャし、文字列 ">" のみを取得するにはどうすればよいですか?