SSH shell: is it different from the Web Shell?

Status
Not open for further replies.

panz

Guru
Joined
May 24, 2013
Messages
556
If I try to enter this command from a SSH (Putty) session:

# for i in 0 1 2 3 4 5; do

then pressing [RETURN] gives me an error.

If I enter the same command from the "built in" shell (the Web interface one) the system accepts the command and (after pressing RETURN) correctly allows me to enter the next command:

> dd if=/dev/ada${i} of=/dev/null bs=1048576 &

Why?
 
D

dlavigne

Guest
Sounds like a different shell. Try typing env|grep SHELL within each to see which login shell it shows.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
or "echo $SHELL" which'll probably show maybe csh or tcsh
or look to see what shell you've got set up for your username in the GUI

the equivalent structure in a C shell derivative would be

# foreach i (0 1 2 3 4 5)
foreach? dd if=/dev/ada${i} of=/dev/null bs=1048576 &
foreach? end
#
 

panz

Guru
Joined
May 24, 2013
Messages
556
Sounds like a different shell. Try typing env|grep SHELL within each to see which login shell it shows.

env|grep SHELL (from "Web" CLI)
SHELL=/usr/local/bin/bash

env|grep SHELL (from SSH Putty session)
SHELL=/bin/csh
 

panz

Guru
Joined
May 24, 2013
Messages
556
or "echo $SHELL" which'll probably show maybe csh or tcsh
or look to see what shell you've got set up for your username in the GUI

the equivalent structure in a C shell derivative would be

# foreach i (0 1 2 3 4 5)
foreach? dd if=/dev/ada${i} of=/dev/null bs=1048576 &
foreach? end
#

Thank you! How do I monitor that command if I leave the shell or the SSH session is accidentally interrupted?
 

panz

Guru
Joined
May 24, 2013
Messages
556
or "echo $SHELL" which'll probably show maybe csh or tcsh
or look to see what shell you've got set up for your username in the GUI

the equivalent structure in a C shell derivative would be

# foreach i (0 1 2 3 4 5)
foreach? dd if=/dev/ada${i} of=/dev/null bs=1048576 &
foreach? end
#

Thank you jgreco, very informative!

How do I change the shell for SSH to be Bash? From view users --> edit root? Is there any risk doing that? (internal script that will not work anymore, etc.)
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
Not that I'm aware of. I expect the reason for the initial question was due to the fact that the WebGUI "shell" is probably derived from the boot environment (which is what starts up the GUI) while the login shell is derived from the password file.
 

panz

Guru
Joined
May 24, 2013
Messages
556
My question was due to the fact that I tried your suggestions for hard drive "stress" tests entering all the commands from a SSH session: this didn't work; so I tried from the Terminal offered by the WebGUI.

I was wondering if there is an actual technical reason to have different shell(s).
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
I was wondering if there is an actual technical reason to have different shell(s).

Well, I ought to say something rude but I understand the context of the question a bit better than that.

My guess is that the intent of the GUI based "shell" is for debugging and testing, so it would be most useful to give out something consistent to users to prevent anyone providing support from having to guess at the shell while trying to provide support. It is also completely possible that whoever wrote the code didn't consider the possibility that someone might want a different shell there, so whatever is in the default environment at boot time comes up. Either way, I'd say there's an argument for consistency.

As for ssh-based or console-based shell access, the UNIX guys among us (including me) would be up in arms if they forced a specific shell, because many of us are rather particular. For example, I hate bash; I do most of my scripting in sh and daily work in tcsh. bash is the worst of several different worlds all mashed up into an awful thing that is these days also often called "sh", meaning that newcomers to shell scripting learn bash-isms when writing scripts that they say are actually for /bin/sh, which then promptly break on systems with real sh. Ugh.
 
Status
Not open for further replies.
Top