executing REMEMBERLOGIN from VS returns error

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
jp1982
Posts: 28
Joined: Fri Aug 27, 2010 3:23 pm

executing REMEMBERLOGIN from VS returns error

Post by jp1982 » Tue May 03, 2011 1:26 am

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!

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: executing REMEMBERLOGIN from VS returns error

Post by lbauer » Tue May 03, 2011 7:44 am

We could use more information on what you are trying to do with your app and the Rememberlogin.
Linda Bauer
SourceGear
Technical Support Manager

jp1982
Posts: 28
Joined: Fri Aug 27, 2010 3:23 pm

Re: executing REMEMBERLOGIN from VS returns error

Post by jp1982 » Tue May 03, 2011 11:20 am

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 :roll: Thanks!

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: executing REMEMBERLOGIN from VS returns error

Post by lbauer » Tue May 03, 2011 12:23 pm

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.
Linda Bauer
SourceGear
Technical Support Manager

jp1982
Posts: 28
Joined: Fri Aug 27, 2010 3:23 pm

Re: executing REMEMBERLOGIN from VS returns error

Post by jp1982 » Tue May 03, 2011 3:20 pm

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.

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: executing REMEMBERLOGIN from VS returns error

Post by lbauer » Wed May 04, 2011 3:56 pm

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

jp1982
Posts: 28
Joined: Fri Aug 27, 2010 3:23 pm

Re: executing REMEMBERLOGIN from VS returns error

Post by jp1982 » Wed May 04, 2011 6:49 pm

No, all of them have no spaces between them.

jp1982
Posts: 28
Joined: Fri Aug 27, 2010 3:23 pm

Re: executing REMEMBERLOGIN from VS returns error

Post by jp1982 » Thu May 05, 2011 6:55 pm

jp1982 wrote:No, all of them have no spaces between them.
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
Posts: 28
Joined: Fri Aug 27, 2010 3:23 pm

Re: executing REMEMBERLOGIN from VS returns error

Post by jp1982 » Thu May 05, 2011 7:00 pm

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!

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: executing REMEMBERLOGIN from VS returns error

Post by lbauer » Fri May 06, 2011 9:24 am

It's the "Tech Touch." Contact Tech Support about a problem and the app starts behaving itself.
Linda Bauer
SourceGear
Technical Support Manager

Post Reply