Changeset 99773 in vbox
- Timestamp:
- May 12, 2023 12:13:40 PM (17 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
doc/manual/en_US/man_VBoxManage-guestcontrol.xml (modified) (3 diffs)
-
src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/en_US/man_VBoxManage-guestcontrol.xml
r99498 r99773 55 55 </group> 56 56 <arg choice="plain">run</arg> 57 <arg>--arg0=<replaceable>argument 0</replaceable></arg> 57 58 <arg>--domain=<replaceable>domainname</replaceable></arg> 58 59 <arg>--dos2unix</arg> … … 90 91 </group> 91 92 <arg choice="plain">start</arg> 93 <arg>--arg0=<replaceable>argument 0</replaceable></arg> 92 94 <arg>--domain=<replaceable>domainname</replaceable></arg> 93 95 <arg>--exe=<replaceable>filename</replaceable></arg> … … 1367 1369 --username user1 --passwordfile pw.txt 1368 1370 </screen> 1371 <para> 1372 The following <command>VBoxManage guestcontrol run</command> 1373 command executes a <command>/usr/bin/busybox -l /usr</command> 1374 command on the <literal>My OL VM</literal> Oracle Linux VM as the 1375 <literal>user1</literal> user, explicitly using <literal>ls</literal> 1376 as argument 0. 1377 </para> 1378 <screen> 1379 $ VBoxManage --nologo guestcontrol "My OL VM" run --exe "/usr/bin/busybox" \ 1380 --username user1 --passwordfile pw.txt --wait-stdout --arg0 ls -- -l /usr 1381 </screen> 1382 <para> 1383 The <option>--exe</option> option specifies the absolute path of 1384 the command to run in the guest VM, <filename>/usr/bin/busybox</filename>. 1385 Use the <option>--</option> option to pass any arguments that 1386 follow it to the <command>busybox</command> command. 1387 </para> 1388 <para> 1389 Use the <option>--username</option> option to specify the user 1390 name, <literal>user1</literal> and use the 1391 <option>--passwordfile</option> option to specify the name of a 1392 file that includes the password for the <literal>user1</literal> 1393 user, <filename>pw.txt</filename>. 1394 </para> 1395 <para> 1396 The <option>--wait-stdout</option> option waits for the 1397 <command>ls</command> guest process to complete before providing 1398 the exit code and the command output. The 1399 <option>--nologo</option> option suppresses the output of the logo 1400 information. 1401 </para> 1402 <para> 1403 The <option>--arg0</option> option explicitly specifies the argument 0 1404 to use for the command to execute. 1405 </para> 1406 <para> 1407 The default behavior of argument 0 is to either use 1408 the value from <option>--exe</option>, or, if not set, the first 1409 value passed after <option>--</option>. 1410 </para> 1369 1411 </refsect1> 1370 1412 </refentry> -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r99754 r99773 1170 1170 { 1171 1171 GCTLCMD_COMMON_OPTION_DEFS() 1172 { "--arg0", '0', RTGETOPT_REQ_STRING }, 1172 1173 { "--cwd", 'C', RTGETOPT_REQ_STRING }, 1173 1174 { "--putenv", 'E', RTGETOPT_REQ_STRING }, … … 1201 1202 com::SafeArray<IN_BSTR> aEnv; 1202 1203 const char * pszImage = NULL; 1204 const char * pszArg0 = NULL; /* Argument 0 to use. pszImage will be used if not specified. */ 1203 1205 const char * pszCwd = NULL; 1204 1206 bool fWaitForStdOut = fRunCmd; … … 1241 1243 case kGstCtrlRunOpt_Profile: 1242 1244 aCreateFlags.push_back(ProcessCreateFlag_Profile); 1245 break; 1246 1247 case '0': 1248 pszArg0 = ValueUnion.psz; 1243 1249 break; 1244 1250 … … 1290 1296 1291 1297 case VINF_GETOPT_NOT_OPTION: 1292 aArgs.push_back(Bstr(ValueUnion.psz).raw()); 1298 /* VINF_GETOPT_NOT_OPTION comes after all options have been specified; 1299 * so if pszImage still is zero at this stage, we use the first non-option found 1300 * as the image being executed. */ 1293 1301 if (!pszImage) 1294 {1295 Assert(aArgs.size() == 1);1296 1302 pszImage = ValueUnion.psz; 1297 } 1303 else /* Add anything else to the arguments vector. */ 1304 aArgs.push_back(Bstr(ValueUnion.psz).raw()); 1298 1305 break; 1299 1306 … … 1307 1314 if (!pszImage || !*pszImage) 1308 1315 return errorSyntax(GuestCtrl::tr("No executable specified!")); 1316 1317 /* Set the arg0 argument (descending precedence): 1318 * - If an argument 0 is explicitly specified (via "--arg0"), use this as argument 0. 1319 * - When an image is specified explicitly (via "--exe <image>"), use <image> as argument 0. 1320 * Note: This is (and ever was) the default behavior users expect, so don't change this! */ 1321 if (pszArg0) 1322 aArgs.push_front(Bstr(pszArg0).raw()); 1323 else 1324 aArgs.push_front(Bstr(pszImage).raw()); 1325 1326 if (pCtx->cVerbose) /* Print the final execution parameters in verbose mode. */ 1327 { 1328 RTPrintf(GuestCtrl::tr("Executing:\n Image : %s\n"), pszImage); 1329 for (size_t i = 0; i < aArgs.size(); i++) 1330 RTPrintf(GuestCtrl::tr(" arg[%d]: %ls\n"), i, aArgs[i]); 1331 } 1332 /* No altering of aArgs and/or pszImage after this point! */ 1309 1333 1310 1334 /*
Note:
See TracChangeset
for help on using the changeset viewer.

