Operating System - HP-UX
1753485 Members
4471 Online
108794 Solutions
New Discussion юеВ

Re: Why I need to run sh to use vi

 
Anh-Thu Tran
Frequent Advisor

Why I need to run sh to use vi

When I login, my current shell is ksh. However, I can not use vi to open a file. It was hanging and I had to ctr+C to exit. After that, I run sh command to change shell, and I was able to vi file. My shell is still ksh. That mean nothing change, but at least I can vi a file. So why I have to run sh first to use vi? I have no EDITOR variable setup in my .profile. Thanks.
6 REPLIES 6
Steven E. Protter
Exalted Contributor

Re: Why I need to run sh to use vi

Shalom,

Our default environment apparently lacks variables needed to run vi.

After you run sh you get a new environment that lets vi work.

/etc/profile or .profile are missing the source of variables needed for vi.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
V. Nyga
Honored Contributor

Re: Why I need to run sh to use vi

Hi,

you can check your shells with 'which vi' to see if the shell recognizes the command.
Also you can add:
EDITOR=vi
export EDITOR

in your .profile.

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
BIHAN
Frequent Advisor

Re: Why I need to run sh to use vi

check $TERM enviromnment variable
if not set try to force the value in the .profile (look at the tset commands in this file)

try this too
# reset
and/or
# resize
before starting vi


(note that starting ksh will not reload the profile files nor the .kshrc, it is done with a login shell)

Frank de Vries
Respected Contributor

Re: Why I need to run sh to use vi

That is odd.

ksh and sh should be compatible with vi.
bash is not by default.

To Open an appropriate shell and ensure
export EDITOR=vi
set -o vi
is only make things more comfortable,
but
principaly it should work from the first
shell.



Look before you leap
V. Nyga
Honored Contributor

Re: Why I need to run sh to use vi

Hi again,

I think your ksh-shell doesn't 'know' the path of vi.
'which vi' -> /usr/bin/vi

Check if /usr/bin is in your /etc/PATH.
You could also check with 'env|grep PATH' if the path is known in ksh or sh.
Look for differences between both shells.
You can expand /etc/PATH with /usr/bin.
After a new login it should work.

V.
*** Say 'Thanks' with Kudos ***
Dennis Handly
Acclaimed Contributor

Re: Why I need to run sh to use vi

>V. Nyga: I think your ksh-shell doesn't 'know' the path of vi.

It finds a vi since Anh-Thu said it was hanging.

>'which vi' -> /usr/bin/vi

The proper real shell command is "whence vi". It just may not be /usr/bin/vi.