executing REMEMBERLOGIN from VS returns error
Moderator: SourceGear
executing REMEMBERLOGIN from VS returns error
Hello Sourcegear team!
I am trying to execute the REMEMBERLOGIN from my C# app. I have the following code which is very similar to the one I use to call vault BATCH [filename]
......
string strParams = "-host {0} -user {1} -password {2} -repository {3}";
return ExecCmdLineCommand("REMEMBERLOGIN " + string.Format(strParams, vaultHost, vaultUser, vaultPassword, vaultRepository));
......
The ExecCmdLineCommand has the following code. cmdLineExePath is a static string which points to the vault.exe in my program files folder. the parameter vault command receives the following string containing the options needed for setting the login:
vaultCommand = REMEMBERLOGIN -host [MyHost] -user [MyUser] -password [MyPass] -repository [MyRepo]
public static bool ExecCmdLineCommand(string vaultCommand)
{
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.FileName = cmdLineExePath;
startInfo.Arguments = vaultCommand;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
Process p = Process.Start(startInfo);
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
string error = @"success=""no"" ";
if (output.Length > 0 && output.Contains(error))
strSuccess = false;
else
strSuccess = true;
}
catch (Exception ex)
{
strSuccess = false;
}
}
The output returns the following:
<vault>
<error>
This command accepts no arguments.
</error>
<result success="no" />
</vault>
I can execute the command formed (vault.exe vaultcommand) from my cmd.exe and works just fine. I do the same thing when getting versions for some files from the server via a batch file and works just fine (vault.exe batch filename). I assume the options specified on REMEMBERLOGIN for Vault are not arguments which makes it blow. Am I missing something? Is there other way to accomplish this correctly? I also intend to do the same for SETTINGWORKINGFOLDER which I've not tested yet.
Thanks! I appreciate your help!
I am trying to execute the REMEMBERLOGIN from my C# app. I have the following code which is very similar to the one I use to call vault BATCH [filename]
......
string strParams = "-host {0} -user {1} -password {2} -repository {3}";
return ExecCmdLineCommand("REMEMBERLOGIN " + string.Format(strParams, vaultHost, vaultUser, vaultPassword, vaultRepository));
......
The ExecCmdLineCommand has the following code. cmdLineExePath is a static string which points to the vault.exe in my program files folder. the parameter vault command receives the following string containing the options needed for setting the login:
vaultCommand = REMEMBERLOGIN -host [MyHost] -user [MyUser] -password [MyPass] -repository [MyRepo]
public static bool ExecCmdLineCommand(string vaultCommand)
{
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.FileName = cmdLineExePath;
startInfo.Arguments = vaultCommand;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
Process p = Process.Start(startInfo);
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
string error = @"success=""no"" ";
if (output.Length > 0 && output.Contains(error))
strSuccess = false;
else
strSuccess = true;
}
catch (Exception ex)
{
strSuccess = false;
}
}
The output returns the following:
<vault>
<error>
This command accepts no arguments.
</error>
<result success="no" />
</vault>
I can execute the command formed (vault.exe vaultcommand) from my cmd.exe and works just fine. I do the same thing when getting versions for some files from the server via a batch file and works just fine (vault.exe batch filename). I assume the options specified on REMEMBERLOGIN for Vault are not arguments which makes it blow. Am I missing something? Is there other way to accomplish this correctly? I also intend to do the same for SETTINGWORKINGFOLDER which I've not tested yet.
Thanks! I appreciate your help!
Re: executing REMEMBERLOGIN from VS returns error
We could use more information on what you are trying to do with your app and the Rememberlogin.
Linda Bauer
SourceGear
Technical Support Manager
SourceGear
Technical Support Manager
Re: executing REMEMBERLOGIN from VS returns error
What I am trying to do is, before processing my batch file I want to set the REMEMBERLOGIN in order for me to not pass the vault connection parameters in each command. I know once you run it you do not need it anymore, but at the end of the whole process I also intend to exec the FORGETLOGIN.
Since our passwords change on a time basis, I want to make sure this does not fail when that happens so getting the login info prior starting the whole process and setting the REMEMBERLOGIN seems like a good idea.
Let me know if I made myself clear enough, sometimes I try to explain stuff very detailed and finish making it worse Thanks!
Since our passwords change on a time basis, I want to make sure this does not fail when that happens so getting the login info prior starting the whole process and setting the REMEMBERLOGIN seems like a good idea.
Let me know if I made myself clear enough, sometimes I try to explain stuff very detailed and finish making it worse Thanks!
Re: executing REMEMBERLOGIN from VS returns error
Are you trying to automatically log in from Visual Studio? Are you executing the script from Visual Studio?
Not sure how VS factors in here.
Not sure how VS factors in here.
Linda Bauer
SourceGear
Technical Support Manager
SourceGear
Technical Support Manager
Re: executing REMEMBERLOGIN from VS returns error
Yes, my app will be executed from command line. It will basically log to vault get the versions for specified files that are contained in the batch file I will be using for processing.
So initially, because of the password changes I want to add a step from remembering the login and setting the working folder and once that is set, process my batch file once it is done, un-setting the working folder and forgetting the login. Everything works if I set the first 2 steps (remember login and setting working folder) prior executing my app but I want to include them as part of the process so I do not have to exec them from the outside.
So initially, because of the password changes I want to add a step from remembering the login and setting the working folder and once that is set, process my batch file once it is done, un-setting the working folder and forgetting the login. Everything works if I set the first 2 steps (remember login and setting working folder) prior executing my app but I want to include them as part of the process so I do not have to exec them from the outside.
Re: executing REMEMBERLOGIN from VS returns error
To any of the values in your Vault command have spaces in them, such as the username, password, etc.?
Linda Bauer
SourceGear
Technical Support Manager
SourceGear
Technical Support Manager
Re: executing REMEMBERLOGIN from VS returns error
No, all of them have no spaces between them.
Re: executing REMEMBERLOGIN from VS returns error
Actually I do have spaces in one parameter, which is the parameter name. Sorry I missed it. You think that is what is causing the error?jp1982 wrote:No, all of them have no spaces between them.
Re: executing REMEMBERLOGIN from VS returns error
So I just tried this again and it just worked fine. Same code as before with no actual changes. Maybe my VS went crazy for a while, so this is no longer an error. Thanks for your help!
Re: executing REMEMBERLOGIN from VS returns error
It's the "Tech Touch." Contact Tech Support about a problem and the app starts behaving itself.
Linda Bauer
SourceGear
Technical Support Manager
SourceGear
Technical Support Manager