Changeset 28354 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Apr 15, 2010 12:34:53 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60114
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r28347 r28354 64 64 RTPrintf("VBoxManage guestcontrol execute <vmname>|<uuid>\n" 65 65 " <path to program> [--arguments \"<arguments>\"] [--environment \"NAME=VALUE NAME=VALUE\"]\n" 66 " [--flags <flags>] [-- username <name> [--password <password>]]\n"67 " [-- timeout <msec>] [--verbose] [--wait stdout[,[stderr]]]\n"66 " [--flags <flags>] [--timeout <msec>] [--username <name> [--password <password>]\n" 67 " [--verbose] [--wait-for exit]\n" 68 68 "\n"); 69 69 } … … 87 87 Utf8Str Utf8UserName; 88 88 Utf8Str Utf8Password; 89 uint32_t uTimeoutMS = RT_INDEFINITE_WAIT; 90 bool waitForOutput = false; 89 uint32_t uTimeoutMS = 0; 90 bool waitForExit = false; 91 bool waitForStdOut = false; 92 bool waitForStdErr = false; 91 93 bool verbose = false; 92 94 … … 176 178 ++i; 177 179 } 178 else if (!strcmp(a->argv[i], "--wait")) 179 { 180 if (i + 1 >= a->argc) 181 usageOK = false; 182 else 183 { 184 /** @todo Check for "stdout" or "stderr"! */ 185 waitForOutput = true; 180 else if (!strcmp(a->argv[i], "--wait-for")) 181 { 182 if (i + 1 >= a->argc) 183 usageOK = false; 184 else 185 { 186 if (!strcmp(a->argv[i + 1], "exit")) 187 waitForExit = true; 188 else if (!strcmp(a->argv[i + 1], "stdout")) 189 waitForStdOut = true; 190 else if (!strcmp(a->argv[i + 1], "stderr")) 191 waitForStdErr = true; 192 else 193 usageOK = false; 186 194 ++i; 187 195 } … … 243 251 ULONG uPID = 0; 244 252 245 if (verbose) RTPrintf("Waiting for guest to start process ...\n"); 253 if (verbose) 254 { 255 if (uTimeoutMS == 0) 256 RTPrintf("Waiting for guest to start process ...\n"); 257 else 258 RTPrintf("Waiting for guest to start process (within %ums)\n", uTimeoutMS); 259 } 260 261 /* Get current time stamp to later calculate rest of timeout left. */ 262 uint32_t uStartMS = RTTimeMilliTS(); 263 264 /* Execute the process. */ 246 265 CHECK_ERROR_BREAK(guest, ExecuteProcess(Bstr(Utf8Cmd), uFlags, 247 266 ComSafeArrayAsInParam(args), ComSafeArrayAsInParam(env), … … 250 269 &uPID, progress.asOutParam())); 251 270 if (verbose) RTPrintf("Process '%s' (PID: %u) started.\n", Utf8Cmd.raw(), uPID); 252 if (waitForOutput) 253 { 254 if (verbose) RTPrintf("Waiting for output ...\n"); 255 /** @todo */ 256 } 257 /** @todo Show some progress here? */ 271 if (waitForExit) 272 { 273 /* Calculate timeout value left after process has been started. */ 274 if (uTimeoutMS) 275 uTimeoutMS = uTimeoutMS - (RTTimeMilliTS() - uStartMS); 276 if (verbose) 277 { 278 if (uTimeoutMS == 0) 279 RTPrintf("Waiting for process to exit ...\n"); 280 else 281 RTPrintf("Waiting for process to exit (%ums left) ...\n", uTimeoutMS); 282 } 283 284 /* Wait for process to exit ... */ 285 ASSERT(progress); 286 rc = progress->WaitForCompletion(uTimeoutMS == 0 ? -1 /* Wait forever */ : uTimeoutMS); 287 if (FAILED(rc)) 288 { 289 if (uTimeoutMS) 290 RTStrmPrintf(g_pStdErr, "Process '%s' (PID: %u) did not end within %ums! Wait aborted.\n", 291 Utf8Cmd.raw(), uPID, uTimeoutMS); 292 break; 293 } 294 else 295 { 296 BOOL completed; 297 CHECK_ERROR_RET(progress, COMGETTER(Completed)(&completed), rc); 298 ASSERT(completed); 299 300 LONG iRc; 301 CHECK_ERROR_RET(progress, COMGETTER(ResultCode)(&iRc), rc); 302 303 if (verbose) 304 RTPrintf("Process completed.\n"); 305 306 /* Print output if wanted. */ 307 if ( waitForStdOut 308 || waitForStdErr) 309 { 310 Bstr strOutput; 311 CHECK_ERROR_BREAK(guest, GetProcessOutput(strOutput.asOutParam(), 0 /* @todo */)); 312 if (verbose) 313 RTPrintf("Output is:\n"); 314 //RTPrintf(strOutput.raw()); 315 } 316 } 317 } 258 318 a->session->Close(); 259 319 } while (0);
Note:
See TracChangeset
for help on using the changeset viewer.