Adding Directories to PATH in HP-UX with csh


 
Thread Tools Search this Thread
Operating Systems HP-UX Adding Directories to PATH in HP-UX with csh
# 1  
Old 07-09-2013
Wrench Adding Directories to PATH in HP-UX with csh

HI Guys,
I am truing to add some directories to the productive HP-UX (like /usr/sbin)
the problem is that i tried some methods like (export) and setenv but i failed.
I add some logs output of the commands to provide you with more info .
the user which I am trying to add this path is different with the root user.
for root user the output of the (echo $PATH is only two directories and is different with the user in use for the services.

Logs are as following:
Code:
#echo $PATH[/COLOR][/B]
/opt/local/bin:/opt/NSCPnav/bin:/oracle/db/product/11.1.0/db_1/bin:/enip/enipapp/cbp/add-ons/bin:
/enip/enipapp/cbp/bin:/enip/enipapp/cbp/service/sys/servicerun/bin:/enip/enipapp/cbp/service/app/servicerun/bin:.:
/opt/informix/informix_server/bin:/enip/enipapp/cbp/tools:/enip/enipapp/cbp/tools/bin:/enip/enipapp/cbp/ext/cbe/tools:
/enip/enipapp/cbp/bin:/opt/freeware/bin:/usr/vacpp/bin:/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/usr/contrib/Q4/bin:/opt/perl/bin:
/opt/ipf/bin:/opt/gvsd/bin:/opt/nettladm/bin:/opt/fcms/bin:/opt/wbem/bin:/opt/wbem/sbin:/opt/sas/bin:/opt/graphics/common/bin:
/opt/atok/bin:/usr/bin/X11:/usr/contrib/bin/X11:/opt/sec_mgmt/bastille/bin:/opt/caliper/bin:/opt/drd/bin:/opt/dsau/bin:
/opt/dsau/sbin:/opt/resmon/bin:/opt/firefox:/opt/gnome/bin:/opt/ignite/bin:/opt/propplus/bin:/usr/contrib/kwdb/bin:/opt/mozilla:
/opt/perl_32/bin:/opt/perl_64/bin:/opt/prm/bin:/opt/sfm/bin:/opt/swm/bin:/opt/sec_mgmt/spc/bin:/opt/ssh/bin:/opt/sentinel/bin:
/opt/swa/bin:/opt/hpsmh/bin:/opt/thunderbird:/opt/langtools/bin:/opt/gwlm/bin:/opt/cfg2html:.:/opt/aCC/bin

the Profile:
Code:
cat /etc/profile

# @(#)B.11.31_LR     

# Default (example of) system-wide profile file (/usr/bin/sh initialization).
# This should be kept to the bare minimum every user needs.

# Ignore HUP, INT, QUIT now.

        trap "" 1 2 3                           
        
# Set the default paths - Do NOT modify these.
# Modify the variables through /etc/PATH and /etc/MANPATH 

        PATH=/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/usr/contrib/Q4/bin:/opt/perl/bin
        MANPATH=/usr/share/man:/usr/contrib/man:/usr/local/man

# Insure PATH contains either /usr/bin or /sbin (if /usr/bin is not available).

        if [ ! -d /usr/sbin ]
        then
                PATH=$PATH:/sbin

        else    if [ -r /etc/PATH ]
                then

                # Insure that $PATH includes /usr/bin .  If /usr/bin is 
                # present in /etc/PATH then $PATH is set to the contents 
                # of /etc/PATH.  Otherwise, add the contents of /etc/PATH 
                # to the end of the default $PATH definition above.

                        grep -q -e "^/usr/bin$" -e "^/usr/bin:" -e ":/usr/bin:"\
                                -e ":/usr/bin$" /etc/PATH
                        if [ $? -eq 0 ]
                        then
                                PATH=`cat /etc/PATH`
                        else
                                PATH=$PATH:`cat /etc/PATH`
                        fi
                fi
        fi

        export PATH

# Set MANPATH to the contents of /etc/MANPATH, if it exists.

        if [ -r /etc/MANPATH ]
        then
                MANPATH=`cat /etc/MANPATH`
        fi

        export MANPATH

# Set the TIMEZONE      

        if [ -r /etc/TIMEZONE ]
        then
           . /etc/TIMEZONE      
        else
            TZ=MST7MDT               # change this for local time.  
            export TZ
        fi

# Be sure that VUE does not invoke tty commands

   if [ ! "$VUE" ]; then

   # set term if it's not set

        if [ "$TERM" = "" -o "$TERM" = "unknown" -o "$TERM" = "dialup"  \
             -o "$TERM" = "network" ]
        then
                eval `ttytype -s -a`
        fi

        export TERM

   # set erase to ^H, if ERASE is not set
        if [ "$ERASE" = "" ]
        then
                ERASE="^H"
                export ERASE
        fi
        stty erase $ERASE

   # Set up shell environment:

        trap "echo logout" 0


   # This is to meet legal requirements...

        cat /etc/copyright

   # Message of the day

        if [ -r /etc/motd ]
        then
                cat /etc/motd
        fi

   # Notify if there is mail

        if [ -f /usr/bin/mail ]
        then
                if mail -e
                then    echo "You have mail."
                fi
        fi

   # Notify if there is news

        if [ -f /usr/bin/news ]
        then news -n
        fi

   # Change the backup tape

        if [ -r /tmp/changetape ]
        then    echo "\007\nYou are the first to log in since backup:"
                echo "Please change the backup tape.\n"
                rm -f /tmp/changetape
        fi

   fi                                           # if !VUE

# Leave defaults in user environment.

   trap 1 2 3

for the root user:
Code:
echo $PATH
/usr/bin:/usr/sbin:/sbin


Last edited by Scott; 07-09-2013 at 07:17 PM.. Reason: Please use code tags
# 2  
Old 07-09-2013
if you are using csh, set the PATH variable in $HOME/.cshrc or $HOME/.login ...

when you login as root either through su - or directly on the console, you will get the environment set by $HOME/.profile and/or /etc/profile because root's default shell is sh ...

however -- when you change your shell to csh -- the environment set is based on the default PATH (see man csh) if $HOME/.cshrc or $HOME/.login does not exist ...

setting csh path
# 3  
Old 07-10-2013
You should know that on HP-UX root uses by default /sbin/sh ( till 11.11 anyway...) and when you su to root you have a minimalist PATH set as you have noticed, this was for security reasons ( beeing root means also you know where things are and you can rest PATH if you wish...) this was a way to not people external to the IT team do any damage to the box ( e.g. when someone comes to install some software and asks for root access... )

What you are asking is something trivial for any HP sysadm, but I know none that would use csh... If you read the /etc/profile you would have guessed..
# 4  
Old 07-10-2013
csh uses the path shell variable.
Code:
echo $path
set path = (/usr/barry1946 $path)

The character between each directory in the C shell's $path variable is a space.
# 5  
Old 07-10-2013
csh, by default, uses the path shell variable to search for executables and scripts.
Code:
echo $path
set path = (/usr/barry1946 $path)

The character between each directory in the C shell's $path variable is a space.
# 6  
Old 07-10-2013
csh has a magic link between its path variable and PATH.
The csh fans tell to use path because they think its list format is easier.
But you can use/modify PATH instead (with setenv); with proper "quotes" it is even safer.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding to the end of the path in .profile

Hi there, I have the following in my path: export PATH=/usr/bin:/usr/sbin But I want to change it programmatically(for the purpose of JBoss automatic(ansible) installs) to: export PATH=/usr/bin:/usr/sbin:/usr/jdk/jdk1.8.0_60 and after that I need to insert the JAVA_HOME programmatically,... (7 Replies)
Discussion started by: hvdalsen
7 Replies

2. Shell Programming and Scripting

Print path files in different directories

Hi guys :) First of all Happy New Year :) so i dont know if my doubt its already here posted by other person ... i need to print to one file the path of few files that are in different directories, like this: directory muscle ATP6.aa.muscle.fasta COX1.aa.muscle.fasta . . . ... (2 Replies)
Discussion started by: andreia
2 Replies

3. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

4. Shell Programming and Scripting

Adding # before a line using csh

Hi, I want to grep a word say "fan" from a file and redirect those lines in a file with "#" before them. eg all fan is on i am you you are me i am on fan Expected o/p #fan is on #i am on fan (2 Replies)
Discussion started by: vdhingra123
2 Replies

5. Shell Programming and Scripting

How to get the directory name from a path using csh?

Hi, I want to get ABC and 924 from this path. How can i do so? The length of the path can vary from but end will we same. /home/abs/cad/bad_BAD/vdhingra/testcases/ABC/924/work Similarly, CBA and 234 from this path. /home/abs/cad/aaa/bad_BAD/vdhingra/testcases/CBA/234/work (5 Replies)
Discussion started by: vdhingra123
5 Replies

6. Programming

Improve my shell by adding hierarchical directories.

Hi. im learning unix, and i have problem with my shell . i want to add hierarchical directories. so theshell have mkdir, rmdir and chdir commands. the coding in C language. i looked at the source of mkdir for example, and its very long and complicated. i need simple implementation... (9 Replies)
Discussion started by: evantheking
9 Replies

7. Shell Programming and Scripting

find in given path do not want to traverse to its sub-directories

Hi All, My UNIX Version is: OS Name Release Version AIX appma538 3 5 I want to find certain files with some criterias under the given path. At the same time i want to find the files which resides under the given directory, but normal find traverse to its sub-directories... (4 Replies)
Discussion started by: Arunprasad
4 Replies

8. UNIX for Dummies Questions & Answers

Want to create 3 different new directories under the same path

Hi, Iam new to UNIX...My requirement is to create 3 dir as an hierarchy under /var/opt/temip.The output should be /var/opt/temip/GP_Int/GPTTS/AUTO. I have tried the following script...But only GP_int folder is getting created and not other folders...Can someone help??? #!/usr/bin/ksh #script... (1 Reply)
Discussion started by: Llb
1 Replies

9. Shell Programming and Scripting

Find a file in sub-directories.. o/p just the path

Hello All, I am somehow stumped with this ting. 'Find' will sure show me.. but I want only thepath of all the occurences of the file in any of the sub-dirs.. Any help will be sincerely appreciated. thanx! (3 Replies)
Discussion started by: pranavagarwal
3 Replies

10. UNIX for Dummies Questions & Answers

adding PATH variable

Hello i use bash and i added a path variable for 2 files /rscr and /uscr in /etc/profile /rscr working fine but the other one shows command not found and when i try to type whereis for scripts in /rscr it shows them but the other one shows nothing... thanks :b: (3 Replies)
Discussion started by: wir3d
3 Replies
Login or Register to Ask a Question