Changeset 27773 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Mar 29, 2010 10:11:52 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r27705 r27773 61 61 void usageGuestControl(void) 62 62 { 63 RTPrintf("VBoxManage guestcontrol exec <vmname>|<uuid>\n" 64 " <program> <arguments>\n" 63 RTPrintf("VBoxManage guestcontrol execute <vmname>|<uuid>\n" 64 " <path to program> [--args <arguments>] [--env NAME=VALUE]\n" 65 " [--flags <flags>] [--user <name> [--password <password>]]\n" 66 " [--timeout <milliseconds>]\n" 65 67 "\n"); 66 68 } … … 74 76 * arguments. 75 77 */ 76 bool usageOK = true; 77 const char *pszName = NULL; 78 const char *pszValue = NULL; 79 const char *pszFlags = NULL; 80 if (a->argc == 3) 81 pszValue = a->argv[2]; 82 else if (a->argc == 4) 83 usageOK = false; 84 else if (a->argc == 5) 85 { 86 pszValue = a->argv[2]; 87 if ( strcmp(a->argv[3], "--flags") 88 && strcmp(a->argv[3], "-flags")) 89 usageOK = false; 90 pszFlags = a->argv[4]; 91 } 92 else if (a->argc != 2) 93 usageOK = false; 94 if (!usageOK) 95 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters"); 96 /* This is always needed. */ 97 pszName = a->argv[1]; 78 /** @todo */ 79 if (a->argc < 2) 80 return errorSyntax(USAGE_GUESTCONTROL, "Incorrect parameters"); 81 const char *pszCmd = a->argv[1]; 82 uint32_t uFlags = 0; 83 const char *pszArgs; 84 com::SafeArray <BSTR> env; 85 const char *pszStdIn = NULL; 86 const char *pszStdOut = NULL; 87 const char *pszStdErr = NULL; 88 const char *pszUserName = NULL; 89 const char *pszPassword = NULL; 90 uint32_t uTimeoutMS = 0; 98 91 92 /* lookup VM. */ 99 93 ComPtr<IMachine> machine; 100 /* assume it's a UUID */94 /* assume it's an UUID */ 101 95 rc = a->virtualBox->GetMachine(Bstr(a->argv[0]), machine.asOutParam()); 102 96 if (FAILED(rc) || !machine) … … 107 101 if (machine) 108 102 { 109 Bstr uuid; 110 machine->COMGETTER(Id)(uuid.asOutParam()); 103 do 104 { 105 Bstr uuid; 106 machine->COMGETTER(Id)(uuid.asOutParam()); 107 108 /* open an existing session for VM - so the VM has to be running */ 109 CHECK_ERROR_BREAK(a->virtualBox, OpenExistingSession(a->session, uuid), 1); 110 111 /* get the mutable session machine */ 112 a->session->COMGETTER(Machine)(machine.asOutParam()); 113 114 /* get the associated console */ 115 ComPtr<IConsole> console; 116 CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam())); 117 118 ComPtr<IGuest> guest; 119 CHECK_ERROR_BREAK(console, COMGETTER(Guest)(guest.asOutParam())); 111 120 112 /* open a session for the VM - new or existing */ 113 if (FAILED (a->virtualBox->OpenSession(a->session, uuid))) 114 CHECK_ERROR_RET (a->virtualBox, OpenExistingSession(a->session, uuid), 1); 115 116 /* get the mutable session machine */ 117 a->session->COMGETTER(Machine)(machine.asOutParam()); 118 119 /** @todo */ 120 121 a->session->Close(); 121 ULONG uPID = 0; 122 CHECK_ERROR_BREAK(guest, ExecuteProgram(Bstr(pszCmd), uFlags, 123 Bstr(pszArgs), ComSafeArrayAsInParam(env), 124 Bstr(pszStdIn), Bstr(pszStdOut), Bstr(pszStdErr), 125 Bstr(pszUserName), Bstr(pszPassword), uTimeoutMS, 126 &uPID)); 127 a->session->Close(); 128 } while (0); 122 129 } 123 130 return SUCCEEDED(rc) ? 0 : 1; … … 137 144 138 145 if (a->argc == 0) 139 return errorSyntax(USAGE_GUEST PROPERTY, "Incorrect parameters");146 return errorSyntax(USAGE_GUESTCONTROL, "Incorrect parameters"); 140 147 141 148 /* switch (cmd) */ … … 144 151 145 152 /* default: */ 146 return errorSyntax(USAGE_GUEST PROPERTY, "Incorrect parameters");153 return errorSyntax(USAGE_GUESTCONTROL, "Incorrect parameters"); 147 154 }
Note:
See TracChangeset
for help on using the changeset viewer.