Q "wget"不适用于
QProcess does not work with "wget"
我正在尝试执行这样的命令:
wget --user=abc --ask-password https://xxxxx.com/file.zip
然后我必须提供密码。
此代码应处理它:
connect(&checkFW, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));
//QString command = "wget --user=abc--ask-password https://xxxxxxx.com";
//checkFW.start("sh",QStringList() << "-c" <<"cd ;"+command);
checkFW.start("wget", QStringList() << "--user=abc" << "--ask-password"<< "https://xxxxxx.com/file.zip");
if (!checkFW.waitForStarted()){
qDebug()<<"Could not start ";
return false;
}
QString cmd = "passwordn";
checkFW.write(cmd.toLatin1());
checkFW.waitForFinished(5000);
QByteArray result = checkFW.readAll();
QString mystr(result);
qDebug()<<"output:"<< mystr;
我多次使用QProcess,但这次我无法工作。一些建议?我尝试了不同的methotds和任何反应。当然,我要求的文件没有下载。
我再次检查,文件已下载到/home目录,而不是应用程序的目录。所以它有效,但没有输出。
您以错误的方式将参数传递给 QProcess。
checkFW.start("wget", QStringList() << "--user=abc" << "--ask-password"<< "https://xxxxxx.com/file.zip");
这是ping(Windows(的例子。
#include <QCoreApplication>
#include <QProcess>
#include <QDebug>
int main(int argc, char *argv[])
{
QProcess proc;
QStringList args;
args << "google.com";
args << "-n";
args << "3";
proc.start("ping", args);
proc.waitForFinished();
qDebug() << proc.readAllStandardOutput();
}
如果你只是把:
checkFW.setProcessChannelMode(QProcess::MergedChannels);
以前:
checkFW.start();
您将在标准输出中获得所有输出,甚至是错误
相关文章:
- OpenGL - 在 NDC 中计算位置适用于着色器,但不适用于'regular'程序
- 使用模板参数重载C++方法:如何使其适用于模板的子类?
- 如何修复我的最大公约数代码?它适用于除零和零以外的所有数字
- 选择排序C++(已修改)并非适用于所有情况
- 无法让"std::enable_if"适用于无作用域枚举
- 请找出我的代码中的错误,它在提交得到错误答案的同时仍然适用于我的所有测试用例
- 确定夏令时是否适用于特定日期
- 是否有一种 STL 算法可以最后找到,但它也适用于指针?
- 十进制到二进制的实现不能完全适用于我大学的检查器。问题或提示可能是什么
- 使用程序集嵌入数据时"Undefined reference"错误,使用适用于窗口的 mingw-w64 编译(COFF 而不是 ELF)
- 为什么 std::vector 适用于类定义中的不完整类型?
- 为什么哈希<常量字符*>适用于字符串而不是字符串变量?
- Lambda适用于最新的Visual Studio,但在其他地方不起作用
- 我该如何文档文档以使文档适用于类成员而不是匿名类型
- 计算 c# 中二进制文件符号的频率不起作用,但适用于等效的 c++ 代码
- 为什么 fstream.open(文件名) 适用于文字而不是生成的字符串?
- 模板重载和 SFINAE 仅适用于函数而不是类
- 为什么链接器不抱怨多个函数定义(仅适用于模板化函数)
- 我可以使用' == '来比较两个向量吗?我试过了,似乎工作正常。但我不知道它是否适用于更复杂的情况
- 延长临时的生命周期,适用于块范围的聚合,但不是通过"新";为什么?