Changeset 27929 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Apr 1, 2010 9:58:23 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r27927 r27929 62 62 { 63 63 RTPrintf("VBoxManage guestcontrol execute <vmname>|<uuid>\n" 64 " <path to program> [--arg s <arguments>] [--envNAME=VALUE]\n"65 " [--flags <flags>] [--user <name> [--password <password>]]\n"64 " <path to program> [--arguments <arguments>] [--environment NAME=VALUE]\n" 65 " [--flags <flags>] [--username <name> [--password <password>]]\n" 66 66 " [--timeout <msec>]\n" 67 67 "\n"); … … 76 76 * arguments. 77 77 */ 78 /** @todo */79 if (a->argc < 2) /* At least the command we want to execute should be present. */78 bool usageOK = true; 79 if (a->argc < 2) /* At least the command we want to execute in the guest should be present :-). */ 80 80 return errorSyntax(USAGE_GUESTCONTROL, "Incorrect parameters"); 81 81 82 Utf8Str Utf8Cmd(a->argv[1]); 82 83 uint32_t uFlags = 0; … … 90 91 uint32_t uTimeoutMS = 0; 91 92 93 /* Iterate through all possible commands (if available). */ 94 for (int i = 2; usageOK && i < a->argc; i++) 95 { 96 if ( !strcmp(a->argv[i], "--arguments") 97 || !strcmp(a->argv[i], "--args")) 98 { 99 if (i + 1 >= a->argc) 100 usageOK = false; 101 else 102 { 103 Utf8Args = a->argv[i + 1]; 104 ++i; 105 } 106 } 107 else if ( !strcmp(a->argv[i], "--environment") 108 || !strcmp(a->argv[i], "--env")) 109 { 110 /** @todo Allow more environment blocks be spcecified per "--environment" 111 * option, e.g. "--environment "FOO=BAR HOHO=HEHE;QWER=ASDF". */ 112 if (i + 1 >= a->argc) 113 usageOK = false; 114 else 115 { 116 env.push_back(Bstr(a->argv[i + 1])); 117 ++i; 118 } 119 } 120 else if (!strcmp(a->argv[i], "--flags")) 121 { 122 if ( i + 1 >= a->argc 123 || RTStrToUInt32Full(a->argv[i + 1], 10, &uFlags) != VINF_SUCCESS) 124 usageOK = false; 125 else 126 ++i; 127 } 128 else if ( !strcmp(a->argv[i], "--username") 129 || !strcmp(a->argv[i], "--user")) 130 { 131 if (i + 1 >= a->argc) 132 usageOK = false; 133 else 134 { 135 Utf8UserName = a->argv[i + 1]; 136 ++i; 137 } 138 } 139 else if ( !strcmp(a->argv[i], "--password") 140 || !strcmp(a->argv[i], "--pwd")) 141 { 142 if (i + 1 >= a->argc) 143 usageOK = false; 144 else 145 { 146 Utf8Password = a->argv[i + 1]; 147 ++i; 148 } 149 } 150 else if (!strcmp(a->argv[i], "--timeout")) 151 { 152 if ( i + 1 >= a->argc 153 || RTStrToUInt32Full(a->argv[i + 1], 10, &uTimeoutMS) != VINF_SUCCESS) 154 usageOK = false; 155 else 156 ++i; 157 } 158 /** @todo Add fancy piping stuff here. */ 159 else 160 { 161 return errorSyntax(USAGE_GUESTCONTROL, 162 "Invalid parameter '%s'", Utf8Str(a->argv[i]).raw()); 163 } 164 } 165 166 if (!usageOK) 167 return errorSyntax(USAGE_GUESTCONTROL, "Incorrect parameters"); 168 169 /* If a password was specified, check if we also got a user name. */ 170 if ( !Utf8Password.isEmpty() 171 && Utf8UserName.isEmpty()) 172 { 173 return errorSyntax(USAGE_GUESTCONTROL, 174 "No user name for password specified!"); 175 } 176 92 177 /* lookup VM. */ 93 178 ComPtr<IMachine> machine;
Note:
See TracChangeset
for help on using the changeset viewer.