Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Dec 09, 2018 11:01 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: No shell output in interactive mode
PostPosted: Thu Apr 19, 2012 11:08 am 
Offline

Joined: Thu Apr 19, 2012 10:48 am
Posts: 3
I have a strange problem which likely has to do with the Linux computer I am trying to connect to in combination with the RB mac shell.

There is the process:
1) I am using an interactive shell on OSX
2) I connect to a linux computer using ssh -l ....
3) I get a prompt to enter in my password
4) I enter my password
5) The shell returns a blank string

Step 5 should return a command prompt line but instead I get no text output from the shell. I know I am connected as I can send commands on the linux computer, however I do not get the output from each command. This is very bizar. When I repeat this process on the mac terminal, everything works fine, and I can see the returned string after I enter my password. In addition, when I use plink with a windows realbasic shell everything works fine.

I don't know what I can do to force the output back to the shell. I as using the cshrc environment on the the linux computer don't know if this has anything to do with my problem.

Does anyone have any thoughts on this problem?


Top
 Profile  
Reply with quote  
 Post subject: Re: No shell output in interactive mode
PostPosted: Fri Apr 20, 2012 3:43 am 
Offline
User avatar

Joined: Fri Oct 28, 2005 7:05 am
Posts: 565
Location: Emsworth, UK
A couple possibilities that spring to mind.

1. Check there is a prompt string set in the remote environment.
Presuming your shell object is called myShell, try adding the following to your code after the password has been accepted.

myShell.WriteLine "set prompt='[%n@%m %c]'"

Does that make a difference?
If so, you can add the set prompt command to the .cshrc file in your home folder on the remote host.

1.1 Might be worth checking you are actually using a csh shell, as it is not so common these days.
echo $SHELL
Should it turn out that you are using bash, the prompt string is held in the PS1 environment variable.

2. Presuming you have a prompt. Check the contents of the input buffer for control characters?
The first character returned is usually 0x0A. Depending on how you process and/or display the data that is returned to your shell object, it can look like you got an empty string.

_________________
Yes it's me in the avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: No shell output in interactive mode
PostPosted: Fri Apr 20, 2012 1:40 pm 
Offline

Joined: Thu Apr 19, 2012 10:48 am
Posts: 3
Thanks for the reply, here's my reply.

1) I can write/send any command to the the shell with myShell.WriteLine "anything" but nothing gets returned. The myShell.WriteLine "set prompt='[%n@%m %c]'" test didn't change that.

When I login using the terminal, i can change the prompt with that command and it works. However, when I place the set prompt line within my .cshrc file it did not actually change the prompt when I login using the terminal. I found this to be strange so I removed all the lines within my .cshrc file with the exception of the set prompt, however that didn't change the fact that the prompt did not change to '[%n@%m %c]' when I login using the terminal, so it likely had no affect when logging on with the RB shell .

1.1) The echo $SHELL returns "/local/bin/tcsh"
I sent an email to the system admin to see if I could switch my default shell to batch and unfortunately at this point, that is not possible.

2) After I enter my password, I do get a returned string from the shell. This return is the last piece of info i get from the shell. The encoding is UTF-8, length:1, length (Bytes): 1, or looking at the string in binary debug, the 3 columns report 00 | 0A | .
I'm not sure what the string is.

What's interesting is when I type "myShell.WriteLine exit", the shell returns the string "Connection to ... closed." So the problem is really isolated to my specific shell environment after I log-on.


Top
 Profile  
Reply with quote  
 Post subject: Re: No shell output in interactive mode
PostPosted: Sat Apr 21, 2012 4:06 am 
Offline
User avatar

Joined: Fri Oct 28, 2005 7:05 am
Posts: 565
Location: Emsworth, UK
andrew070 wrote:
When I login using the terminal, i can change the prompt with that command and it works. However, when I place the set prompt line within my .cshrc file it did not actually change the prompt when I login using the terminal.
I am the first to admit that I find Linux login script processing can be a tad confusing at times. I am in the habit of setting an environment variable at the top of the various .login, .profile, .rc files so I can more easily work out what scripts are being processed at login.

The ssh server can be configured to source whatever scripts the sysadmin wishes. It can be configured to purposefully not source any scripts for security reasons or it may be misconfigured to do the same. I would suggest contacting the sysadmin and asking them exactly what scripts they think should be processed during an ssh login. Test as I suggest and if you find things are not as the sysadmin thinks they are, get them to put it right.

Quote:
2) After I enter my password, I do get a returned string from the shell. This return is the last piece of info i get from the shell. The encoding is UTF-8, length:1, length (Bytes): 1, or looking at the string in binary debug, the 3 columns report 00 | 0A | .
I'm not sure what the string is.
My gut feeling is the fundamental problem lies here and it may be indicative of a poor host setup.

The return is 00, 0A. The first thing that might strike you is that's actually 2 bytes, not 1. The 0A is a linefeed character, which is to be expected. The 00 is a Null character, which could well be problematic.

Quote:
What's interesting is when I type "myShell.WriteLine exit", the shell returns the string "Connection to ... closed."
The disconnect string is being sent by the local shell, i.e. The one used to launch the ssh session.

To me, it looks like the problem is with the remote host. BTW. You can test your code locally on a Mac, by enabling Remote Login in the Sharing section of System Preferences, which starts up the sshd service. You should then be able to ssh user@localhost from Terminal.

Is it possible for you to post the pertinent snippets from your code?
i.e. Where you set up the shell, start the ssh session and read the shell data.

_________________
Yes it's me in the avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: No shell output in interactive mode
PostPosted: Thu Jun 14, 2012 8:19 pm 
Offline

Joined: Thu Apr 19, 2012 10:48 am
Posts: 3
Thanks for the information. I'm not sure what to do at this point. I'm convinced this problem is do to the host setup. There is some odd-ball setting that interferes with the output of each command. I just do not understand how this effect is limited to ssh connections with the Realstudio shell, while everything appears to be fine when connections are through a terminal ssh connection. How does the host distinguish between ssh connections from different applications?

The code I'm using is from the example "Interactive Shell.rbp" There's nothing to the code. The shell is setup in the open method. I've tested the code on other connections and everything works as it should.

mShell = New Shell
mShell.Mode = 2


Top
 Profile  
Reply with quote  
 Post subject: Re: No shell output in interactive mode
PostPosted: Thu Jun 14, 2012 11:15 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
It isn't really valid to compare the terminal with a shell process, in any language. The terminal has so much more environment set up, not to mention it has a real monitor attached to it. There are a great many differences.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group