C++ (Qt)QHostAddress aa; QHostInfo info; info =info.fromName("pupkin"); if (!info.addresses().isEmpty()) { aa = info.addresses().first(); }str=QString("ping %1").arg(aa.toString());QProcess pong;pong.execute(str);
C++ (Qt)QProcess ping;ping.start("ping", QStringList() << "prog.org.ru");if (ping.waitForFinished()) qDebug() << ping.readAll();
C++ (Qt)QTextCodec::setCodecForCStrings(QTextCodec::codecForName("cp-866"));QProcess ping;ping.start("ping", QStringList() << "prog.org.ru");if (ping.waitForFinished()) { int count = 0; while (!ping.atEnd()) qDebug() << ++count << " " << ping.readLine();}
C++ (Qt)QProcess *ping;ping = new QProcess ();connect( ping, SIGNAL(readyReadStandardOutput ()), this, SLOT(print_ping()) ); ping->start("ping", QStringList() << "pupkin" );...... void Proga::print_ping(){ QByteArray output; output = ping->readAllStandardOutput (); ui.textEdit->append(output.data()); //вывод в гуи }