目前这么做的,input1行不通;
input2可行,但相同时无output输出,不知怎么判断;
或者我理解错误,还请指点下
QProcess *proCmd = new QProcess;
connect(proCmd,SIGNAL(readyRead()),this,SLOT(readOut()));
QString input1 = tr("rsh remote_host 'diff file1 file2 &&echo 文件相同||echo 文件不相同' ")
proCmd->start(input1);
//QString input 2= tr("rsh remote_host diff file1 file2");
//proCmd->start(input2);
void readOut()
{
QString output = proCmd->readAll();
cout<<output<<endl;
}
换了种方式实现了:>>我是要比较远程主机两个目录下,相同名称的两个文件内容是否一致<<
在远程机器remote_host上主目录建一个文件比较脚本:cmp_two_file
并chmod +x cmp_two_file
使用:QString input = tr("rsh remote_host cmp_two_file %1").arg(file_name);
ProCmd->start(input);
应用readOut捕捉,参考上面问题;
cmp_two_file内容:
#!/bin/sh
startpath=‘pwd’
startpath1=‘pwd’
diff $startpath/$1 $startpath1 &&echo 文件相同||echo 文件不同