Sponsored Content
Top Forums Shell Programming and Scripting Guidance required in .profile Post 303037385 by apmcd47 on Wednesday 31st of July 2019 04:47:38 AM
Old 07-31-2019
Quote:
Originally Posted by cokedude
Bash is thankfully my default shell. I was trying to solve the problem of when bash does not exist. Ksh is the system default but I changed my personal default to bash. How would I fall back to ksh if bash does not exist?
So basically you are asking, "is my login shell bash or ksh?" And if there is no bash on your system it will be ksh, because that is the default, else you will have changed it by the time your regular .profile has been installed. Your SHELL variable will be set to your login shell and bash, from version 2 at least, will have the BASH_VERSION variable. So, either:
Code:
[ -n "$BASH_VERSION" ] && . ./.bashrc

or
Code:
case "$SHELL" in
*bash) . ./.bashrc ;;
*ksh) . ./.kshrc ;;
esac

should do it.
Quote:
Do older systems not like this? Is that what you were saying with portably?

Code:
if [[ -s ~/.bashrc && /usr/bin/bash ]]; then
    #echo hi
    source ~/.bashrc;
fi

POSIX shell and older shells don't support the double square bracket operator; and the single square bracket operator doesn't support the && and || operators. Personally, I think it's more readable to keep one expression per square bracket operator, whether it is single or double.

Andrew
This User Gave Thanks to apmcd47 For This Post:
 

10 More Discussions You Might Find Interesting

1. 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

2. AIX

NIM Guidance

I've just started to explore NIM and I'm looking for additional information on how to set it up and configure it. I've read through the "NIM A-Z" and have many unanswered questions. One question is how can I have the NIM server pull a mksysb of the clients and can I schedule this to happen... (1 Reply)
Discussion started by: scottsl
1 Replies

3. What is on Your Mind?

Career Guidance

Hi, I am a newbie to Unix, I was introduced to UNIX 8 months back during my Training, I was attracted to Unix as they give complete freedom. I would like to ask how can a OS Admin can go into development field of Unix. Currently I am working in a MNC in Backup- Storage Admin Domain I am... (1 Reply)
Discussion started by: sufi_431
1 Replies

4. Shell Programming and Scripting

A little guidance needed :)

Hi guys, I'm learning the ropes of BASH and am doing a few exercises to see if its sinking in but have gotten stuck on something I KNOW is looking at me right in the face but just isn't registering. I'm creating a script that needs to get specific strings from a line. So using the "ls -l... (9 Replies)
Discussion started by: shadow0001
9 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. Shell Programming and Scripting

guidance required: feed load search & display in shell scripting

Hi All, I am fairly new to Shell Scripting, however learning fast ;-) I have been asked to do the below basic shell script :confused: There are few feed files we are recieving in the server from multiple locations spread out during the day, rite now we are checking manually each file... (2 Replies)
Discussion started by: sachaan
2 Replies

7. AIX

Need guidance on VMStat

I need some guidance on the differences in observations, not sure how significantly different are they. Also, It would be nice to hear on the values and what the obvious tuning for performance missing. Observation 1 ending vmstat -v 3948544 memory pages ending vmstat -v ... (1 Reply)
Discussion started by: Snipper
1 Replies

8. UNIX for Dummies Questions & Answers

Just need some guidance on this nawk

Hi, I am trying to debug some KSH script and it has the nawk portion below. I just want to confirm whether I understand what it does correctly. Example usage of the nawk line is run as below: nawk '/^#/ {next} $1~/^'testp.cfg'$|^'testp.cfg'\.testdb\.com\.ph$/ { c=0 while... (1 Reply)
Discussion started by: newbie_01
1 Replies

9. Shell Programming and Scripting

Need Some guidance on scripting

Hey All, I am newbie on scripting and need some guidance from all the experts here. I am working on one project where I will check the status/health of around ten (10) solaris 10 servers. I have one central server from where I have already setup the passwordless SFTP and setup the cron... (1 Reply)
Discussion started by: supercops
1 Replies

10. AIX

New to AIX. Need Guidance

Hi There, I am new to AIX. I am eager to learn the AIX System administration or if there is any other prerequisite before this. Please can anyone help me or guide how to start with AIX, what all courses and certifications do I need to do. I have basic knowledge of UNIX. Please guide as I am... (3 Replies)
Discussion started by: rahulat302
3 Replies
remove profile(1m)														remove profile(1m)

NAME
remove profile - Removes all profile elements and the profile from the specified name service entry SYNOPSIS
rpccp remove profile profile-entry-name [-s syntax] OPTIONS
Indicates the name syntax of the entry name (optional). The only value for this option is the dce name syntax, which is the default name syntax. Until an alternative name syntax becomes available, specifying the -s option is unnecessary. ARGUMENTS
Indicates the name of the target profile. For an entry in the local cell, you can omit the cell name and specify only the cell-relative name. DESCRIPTION
The remove profile command removes a profile (and all of its elements) from the name service database. The entry name of the profile is required. Privilege Required You need write permission to the CDS object entry (the target profile entry). NOTE
This command is replaced at Revision 1.1 by the dcecp command and may not be provided in future releases of DCE. EXAMPLES
The following commands run RPCCP and remove the profile named /.:/LandS/anthro/molly_o_profile: $ rpccp rpccp> remove profile /.:/LandS/anthro/molly_o_profile RELATED INFORMATION
Commands: add element(1m), remove element(1m), show profile(1m) remove profile(1m)
All times are GMT -4. The time now is 11:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy