grep being cropped - WeOnlyDo Discussion board

grep being cropped (wodSSH / wodSSH.NET)

by mike_mort, Saturday, August 02, 2008, 13:23 (5718 days ago)

I have connected to the server and am wanting to place a new public ket within the authorized_keys file. I am first trying to see whether the new key already exists so that I am not duplicating this within the file.

My code is:

[code]
myCommand = grep ' & frmMainForm.txtOldPublicKey.Text & ' $HOME/.ssh/authorized_keys
tmpString = sshConnection.Execute(myCommand, regex:[$ #>] , 30)
[/code]

When I execute the command it seperates the $HOME/.ssh/authorized_keys and so I dont get the desired result.

In essense it executes grep 'command'. Then when I do a sshConnection.Recieve it shows $HOME/.ssh/authorized_keys. Any help appreciated.

Re: grep being cropped

by wodDamir, Saturday, August 02, 2008, 15:17 (5718 days ago) @ mike_mort

Hi Mike,

Can you please try Send and WaitFor commands instead?

Just do something like:

wodSSH.Send( grep + vbcrlf)
wodSSH.WaitFor( pattern you need to receive)

Does that work?

Regards,
Damba

Re: grep being cropped

by mike_mort, Saturday, August 02, 2008, 16:11 (5718 days ago) @ wodDamir

Hi,

I have tried using the send command and waitfor; however, I still dont seem to get the desired result. Example... If I were using putty I would do this.

[code]
$ uname -a
SunOS 5.8 blah blah blah
$
[/code]

What I want is the output from the command entered first, i.e. 'SunOS blah blah blah'. If I do this:

[code]
ssh.Send( uname -a & vbcrLf)
ssh.WaitFor( $ )
tmpString = ssh.Receive()
[/code]

The tmpstring ends up being just a $. How do I get the output from the command?

Thanks, Mike (Sorry if I am being really dum!)

Re: grep being cropped

by wodDamir, Saturday, August 02, 2008, 16:13 (5718 days ago) @ mike_mort

Mike,

Same as for Execute method. WaitFor method also returns a value, so you should do:

tmpString = ssh.WaitFor(...)

Hope this helps.

Regards,
Damba