The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
$ . ./.profile MikeBigjohn UNIX for Dummies Questions & Answers 3 09-14-2007 04:20 AM
Where can I read about the difference between "..profile" and ".profile" zorrokan UNIX for Dummies Questions & Answers 2 09-05-2007 01:35 AM
Difference between .profile and .~/.profile maneesh mehta SCO 3 12-14-2005 04:35 AM
changed .profile but didnt ./.profile, yet reflected changes yls177 UNIX for Dummies Questions & Answers 4 12-05-2002 11:21 AM
why i have local.profile, local.cshrc,local.login instead of .profile, .login ? abidmalik UNIX for Dummies Questions & Answers 5 08-27-2002 01:47 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-20-2008
JamesByars JamesByars is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 124
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 (permalink)  
Old 02-20-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
On line 11 in your .profile file there is a setenv statement. That generates an error which forces the ksh shell to exit.
  #3 (permalink)  
Old 02-20-2008
JamesByars JamesByars is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 124
Quote:
Originally Posted by jim mcnamara View Post
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.
  #4 (permalink)  
Old 02-20-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
.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.
  #5 (permalink)  
Old 02-20-2008
JamesByars JamesByars is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 124
Quote:
Originally Posted by Perderabo View Post
.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
  #6 (permalink)  
Old 02-20-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
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.
  #7 (permalink)  
Old 02-20-2008
nj78 nj78 is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 103
Quote:
Originally Posted by JamesByars View Post
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 me
Closed Thread

Bookmarks

Tags
unix commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0