0
我有一個C程序嘗試使用(rsh)命令執行遠程命令執行。它試圖拉取IP信息並執行命令。執行我的程序後,我登陸shell提示符。我的C程序成功存在(Strace和ps -ef證實相同)。執行我執行shell命令的程序後,Shell沒有響應第一個輸入字符
當在shell中鍵入任何字符時,shell不響應。它適用於下一次鍵入輸入。
我正在使用bash shell
C程序看起來像這樣。
char *cmdline = "/sbin/ip link show bond0 2>/dev/null && inf=bond0 || inf=eth0;"
"/sbin/ip -6 addr show $inf scope link | /bin/awk '/inet6/ { print \$2 }'";
char *getpeerip = "/usr/bin/rsh $(/sbin/ifconfig eth1 | /bin/awk '/inet/ { print \$2 }'"
"| /bin/awk -F: '{ print \$2 }'"
"| /bin/awk -F. '{ printf \"%%s.%%s.%%s.%d\", \$1, \$2, \$3 }') "
"\"/sbin/ip link show bond0 2>/dev/null && inf=bond0 || inf=eth0;"
"/sbin/ip -6 addr show $inf scope link | /bin/awk '/inet6/ { print \\$2 }'\"";
char lnkbuf[300];
cpid = p_getset->local_addr_ids[i].entity_instance;
if (cpid == getThisCPNum()) {
cmd_file = popen(cmdline, "r");
} else {
sprintf(lnkbuf, getpeerip, 1+getPeerCPSlot());
cmd_file = popen(lnkbuf, "r");
}
if (cmd_file != NULL) {
fgets(lnkbuf, 100, cmd_file);
fclose(cmd_file);
}