int TarExtractTaskHelper::calculateNumberOfFilesToExtract() { ProcessRunner processRunner; Process* process = processRunner.getProcess(); (*process) << "/bin/sh" << "-c" << "tar -t " + mTarFormat + " -f " + mFileToUnpack.getPath() + " | wc -l" ; notifyTaskLogger("Calculating number of files to extract (" + process->getArgumentsAsString() + ")\n", message); process->start(); if (!processRunner.getStderrData().empty()) { notifyTaskLogger("Error while calculating number of files to extract:" + processRunner.getStderrData(), error); return 0; } istringstream toInt(processRunner.getStdoutData()); int numberOfFilesToExtract; toInt >> numberOfFilesToExtract; notifyTaskLogger("Done: " + processRunner.getStdoutData(), message); return numberOfFilesToExtract; }
bool PingCmd::PingTask::isReachable(ProcessRunner& r) { return r.getProcess()->exitCode() == 0; }
bool PingCmd::PingTask::isReachable(ProcessRunner& r) { // some times ping tells me that the host wasn't found but returns an good exit code return r.getProcess()->exitCode() == 0 && r.getOutput().contains("TTL="); }