-
Jul 29th, 2021, 02:47 PM
#1
Thread Starter
Hyperactive Member
SSH not getting 2nd part of result
Hi guys,
I have a GAM server (Google Admin Management)
I need to send commands through my VB.NET application.
Some commands (the query commands) have a straight output, but others (the non query commands) have multiple outputs.
eg:
a query command:
gamuser@gam-server:~$ gam info user SOMEUSER
User: SOMEUSER@DOMAIN.com
First Name: SOME
Last Name: USER
Is a Super Admin: False
Is Delegated Admin: False
2-step enrolled: False
2-step enforced: False
Has Agreed to Terms: True
IP Whitelisted: False
Account Suspended: False
Is Archived: False
Must Change Password: False
Google Unique ID: MYGOOGLEID
Customer ID: MYCUSTOMERID
Mailbox is setup: True
Included in GAL: True
Creation Time: 2010-10-14T14:49:39.000Z
Last login time: 2021-07-28T15:00:07.000Z
Google Org Unit Path: OUPATH
Recovery Phone:
gamuser@gam-server:~$
and a non query command:
gamuser@gam-server:~$ gam update user nousertest password 123456
updating user nousertest@DOMAIN.com...
ERROR: 404: Resource Not Found: userKey - userNotFound
gamuser@gam-server:~$
The problem is that with the non query commands I only get the first part of the result (updating user nousertest@DOMAIN.com...)
and not the second (ERROR: 404: Resource Not Found: userKey - userNotFound)
My code:
Code:
Private Sub GetSSH(GAMServer As String, User As String, Pass As String)
Dim connInfo As New PasswordConnectionInfo(GAMServer, User, Pass)
Dim sshClient As New SshClient(connInfo)
Dim cmd As SshCommand
Using sshClient
sshClient.Connect()
cmd = sshClient.RunCommand("gam update user nousertest password 123456")
Dim asynch = cmd.BeginExecute()
While Not asynch.IsCompleted
System.Threading.Thread.Sleep(1000)
End While
TextBox1.Text = cmd.EndExecute(asynch)
sshClient.Disconnect()
End Using
'This is just to see when the connection is done
Label1.Text = "Done"
End Sub
The TextBox1 is showing only 'updating user nousertest@DOMAIN.com...'
Can someone help me with this?
Thanks
-
Aug 3rd, 2021, 12:43 AM
#2
Re: SSH not getting 2nd part of result
This sounds more like a GAM question than a VB.Net question. Your best hope for getting an answer here is that someone else here has used this GAM server you're talking about.
However, going by what I see, it looks like you're requesting information from the server that doesn't exists. A 404 error is typically used by the HTTP protocol to tell clients that something they are asking for cannot be found.
-
Aug 3rd, 2021, 07:41 AM
#3
Thread Starter
Hyperactive Member
Re: SSH not getting 2nd part of result
Thanks for the reply.
Originally Posted by Niya
This sounds more like a GAM question than a VB.Net question.
I don't think it's a GAM issue, it will happen anywhere that there is a 2 part answer from the SSH server...
Sadly I don't have another example...
Originally Posted by Niya
However, going by what I see, it looks like you're requesting information from the server that doesn't exists. A 404 error is typically used by the HTTP protocol to tell clients that something they are asking for cannot be found.
The error is not the point here...
I'm trying this error on purpose so I can get the 2nd output line...
I will have the same issue if I entered a valid user (but I need the 2nd part for the client side of my app)...
-
Aug 3rd, 2021, 08:16 AM
#4
Re: SSH not getting 2nd part of result
Originally Posted by threeeye
Thanks for the reply.
I don't think it's a GAM issue, it will happen anywhere that there is a 2 part answer from the SSH server...
Sadly I don't have another example...
The error is not the point here...
I'm trying this error on purpose so I can get the 2nd output line...
I will have the same issue if I entered a valid user (but I need the 2nd part for the client side of my app)...
Not exactly an answer to your question but have you considered https://github.com/googleapis/google-api-dotnet-client as this is a programmatic wrapper to the Google Workspace APIs and will probably work better through code.
Automating CLI tools can work but it often is tricky, error prone, and you end up manually parsing a lot of text based responses. It is always possible that you are only getting part of the information due to the CLI not expecting to be called in this way.
-
Aug 3rd, 2021, 08:41 AM
#5
Thread Starter
Hyperactive Member
Re: SSH not getting 2nd part of result
Originally Posted by PlausiblyDamp
Not exactly an answer to your question but have you considered https://github.com/googleapis/google-api-dotnet-client as this is a programmatic wrapper to the Google Workspace APIs and will probably work better through code.
Automating CLI tools can work but it often is tricky, error prone, and you end up manually parsing a lot of text based responses. It is always possible that you are only getting part of the information due to the CLI not expecting to be called in this way.
I will look into this.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|