ksh and .profile


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh and .profile
# 1  
Old 02-20-2008
ksh and .profile

hi,

I have the following in my .profile file:

Code:
    21          set -u
    22          trap "echo 'logout'" 0
    23
    24
    25          EDITOR=vi
    26          export EDITOR
    27
    28          export ENV=x.tm


And x.tm just contains
Code:
echo hello world

I am in the c shell. I was under the impression that if I type ksh, then the .profile will get executed, and it will also execute x.tm. But I do not see hello world printed out.
In addition, if I manually do .profile, then I get

Code:
$ .profile
.profile[11]: setenv:  not found
logout

Can anyone explain why this is so?

Thanks.
# 2  
Old 02-20-2008
On line 11 in your .profile file there is a setenv statement. That generates an error which forces the ksh shell to exit.
# 3  
Old 02-20-2008
Quote:
Originally Posted by JamesByars
hi,


I am in the c shell. I was under the impression that if I type ksh, then the .profile will get executed, and it will also execute x.tm. But I do not see hello world printed out.

Thanks.
Doesn't work like that, if you default login is csh. At least it doesn't work for meSmilie
# 4  
Old 02-20-2008
Quote:
Originally Posted by jim mcnamara
On line 11 in your .profile file there is a setenv statement. That generates an error which forces the ksh shell to exit.
no, this is my line 11:


Code:
     8          then
     9                  eval ` tset -s -Q -m ':?hp' `
    10          else
    11                  eval ` tset -s -Q `
    12          fi

But I think the shell is somehow looking at line 11 of uncommented lines, which seems to be the set -u. In any case, there is NO setenv!

Thanks.
# 5  
Old 02-20-2008
.profile is run automatically when you login with ksh as your login shell, not when you type ksh. You said that you were using csh. tset will notice that and output setenv statements for you. The backticks try to run the output from tset.
# 6  
Old 02-20-2008
Quote:
Originally Posted by Perderabo
.profile is run automatically when you login with ksh as your login shell, not when you type ksh. You said that you were using csh. tset will notice that and output setenv statements for you. The backticks try to run the output from tset.
thanks for the reply, but I am still a little confused.

ok, so .profile is not executed when I type ksh and go to the korn shell. But I would have thought that if I then did .profile in the korn shell, it will at least run that script (which looks like below)


Code:
       if [ "$TERM" = "" ]
        then
                eval ` tset -s -Q -m ':?hp' `
        else
                eval ` tset -s -Q `
        fi
        stty erase "^H" kill "^U" intr "^C" eof "^D"
        tabs

        PATH=$PATH:.

        set -u
        trap "echo 'logout'" 0

        EDITOR=vi
        export EDITOR

        export ENV=x.tm


However, I get:

Code:
$  . ./.profile
ksh: setenv:  not found


I just don't know where this setenv is coming from. It is not in my script!

thanks
# 7  
Old 02-20-2008
Notice that I said "tset will notice that and output setenv statements for you. The backticks try to run the output from tset." That is what is happening. What effect did expect from
eval ` tset -s -Q `

Code:
$
$
$ cat script1
#! /usr/bin/ksh
echo setenv this that
exit 0
$
$
$ cat script2
#! /usr/bin/ksh
eval `./script1`
exit 0
$
$
$
$ ./script1
setenv this that
$ ./script2
./script2: setenv: not found
$

script2 has no setenv statement either. But it is trying to run one.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use stty columns 140 in .profile on ksh

Hi, I am trying to put stty columns 140 in .profile to set column width to 140 so I don't have to manully do it every time. My main goal is to avoid seeing "Terminal too wide" message whenever I try to use vi editor in full screen. I am on korn shell echo $SHELL /bin/ksh So even... (8 Replies)
Discussion started by: pat_pramod
8 Replies

2. Shell Programming and Scripting

"ksh: XYZ: parameter not set" in .profile

Hi, A very basic query. I am working on two different UNIX servers and I see different behaviours for my user id. This has to be a setting in the .profile, but I can't seem to find where :confused: So, in one server if I type echo $XYZDD (a random variable), I get a blank line with no... (2 Replies)
Discussion started by: ALDonP
2 Replies

3. Shell Programming and Scripting

Update ksh .profile to launch bash

Hi I don't have chsh option. I want to launch bash instead of ksh ( or launch bash from ksh .profile) how can I do this ? (1 Reply)
Discussion started by: Sivaswami
1 Replies

4. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

5. Infrastructure Monitoring

trap in etc/profile and user .profile

Hello I really wonder what's trap in etc/profile and in each user .profile. I try to google for it but I think I have no luck. Mostly hit is SNMP traps which I think it is not the same thing. I want to know ... 1. What's a "trap 2 3" means and are there any other value I can set... (4 Replies)
Discussion started by: Smith
4 Replies

6. AIX

"ksh -" as login shell bypassing .profile

Hi all, I am currently trying to tell /bin/ksh to behave like a login shell. I am invoking it from an interactive shell. In the documentation is stated, that calling it with exec ksh - it should behave like a login shell, work 1st on /etc/profile, ~/.profile and so on. I tried that with... (0 Replies)
Discussion started by: zaxxon
0 Replies

7. UNIX for Dummies Questions & Answers

.profile on ksh

Hello, I've a problem with .profile on ksh. I use exceed to connect as a user to my server. When I'm connected, my PS1 variable is $, but on my .profile it is defined like PS1="`/usr/ucb/whoami`@$HOSTNAME# " ... export ENV PAGER HOSTNAME PAGER PATH PS1 MAIL Now... all my alias on... (1 Reply)
Discussion started by: gogol_bordello
1 Replies

8. UNIX for Dummies Questions & Answers

difference between /etc/profile and .profile?

What is the difference between /etc/profile and .profile? (5 Replies)
Discussion started by: gehlnar
5 Replies

9. SCO

Difference between .profile and .~/.profile

what is the difference between these two lines, if we use it in korn shell script: .profile .~/.profile (3 Replies)
Discussion started by: maneesh mehta
3 Replies

10. UNIX for Dummies Questions & Answers

changed .profile but didnt ./.profile, yet reflected changes

hi , i added ls -F to .profile. and i need to do ./.profile for the effect to take effect BUT i didnt and YET the next day when i came to work and log in, the changes took effect. i am on aix. please explain.. thanks (4 Replies)
Discussion started by: yls177
4 Replies
Login or Register to Ask a Question