Results 1 to 5 of 5

Thread: SSH not getting 2nd part of result

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2011
    Posts
    256

    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

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2011
    Posts
    256

    Re: SSH not getting 2nd part of result

    Thanks for the reply.

    Quote Originally Posted by Niya View Post
    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...

    Quote Originally Posted by Niya View Post
    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)...

  4. #4
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: SSH not getting 2nd part of result

    Quote Originally Posted by threeeye View Post
    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.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2011
    Posts
    256

    Re: SSH not getting 2nd part of result

    Quote Originally Posted by PlausiblyDamp View Post
    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
  •  



Click Here to Expand Forum to Full Width