Alias is not working under Bourne Shell


 
Thread Tools Search this Thread
Operating Systems Solaris Alias is not working under Bourne Shell
# 15  
Old 11-11-2015
Wasnt that called 'the usr change/move'? (rh suse deb)
# 16  
Old 11-12-2015
Quote:
Originally Posted by MadeInGermany
Portable shell scripts should start with
Code:
PATH=/bin:/usr/bin:/sbin:/usr/sbin

and then use simple commands.
I would advice for portable scripts to have their shebang adapted to point to the POSIX shell available on the target platform, e.g. on Solaris:
Code:
#!/bin/ksh

or even better for stricter compatibility:
Code:
#!/usr/xpg4/bin/sh

then have the scripts using this PATH:
Code:
PATH=$(getconf PATH):$PATH

and use POSIX commands, options and syntax when applicable. Adding /sbin and /usr/sbin to the PATH makes sense too if the scripts need to run administrative commands.
This User Gave Thanks to jlliagre For This Post:
# 17  
Old 11-16-2015
@RudiC
Code:
root@rrhrprd1 # alias
autoload='typeset -fu'
command='command '
functions='typeset -f'
history='fc -l'
integer='typeset -i'
local=typeset
nohup='nohup '
r='fc -e -'
stop='kill -STOP'
suspend='kill -STOP $$'

@jlliagre
Noted and agreed.

@MadeInGermany
Noted and agreed.

@Sea,
Code:
root@rrhrprd1 # man shopt
No manual entry for shopt.
root@rrhrprd1 # shopt
shopt: not found
root@rrhrprd1 #

---------- Post updated at 11:09 AM ---------- Previous update was at 11:06 AM ----------

Quote:
Originally Posted by sea
What? ��
Shopt is bash specific and shall therefor not run in his bash?

Oh wait, bourne != bourne again.

But either way, i do not think he's using the 'right' SH, as it is located in /sbin.

What is the output of:
Code:
ls -l /sbin/sh

I always thought that shells are (only) in bin.

Anyway, how about writing a function, rather than an alias?
Hth

EDIT: Scratch that, didnt see its in Solaris section (was on mobile)
Workaround
Code:
root@rrhrprd1 # bash
root@rrhrprd1 # alias
alias HC='more /var/tmp/HC/`date +%Y`/`date +%B`/`date +%d`'

I have not changed the default shell for the user.
# 18  
Old 11-19-2015
One more workaround:

1 # Updated .profile file as follows:
Code:
root@singapore # tail -2 .profile
#Prabhu # This command has been given here to auto switch to bash shell upon every login without changing the default shell for root user.
/usr/bin/bash
root@singapore # ps -p $$
   PID TTY         TIME CMD
 21886 pts/3       0:00 sh

2 # New session after the above update:
Code:
root@singapore # ps -p $$
   PID TTY         TIME CMD
 28542 pts/2       0:00 bash

By doing so, I don't have to type bash every time I login to the server.
Alias also works well in this shell.

Thanks for everyone's contribution.
# 19  
Old 11-19-2015
To avoid the double logout issue resulting from such a call, I would recommend using instead:

Code:
exec /usr/bin/bash

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Lost with this alias why it is not working

Hi, I have the following aliases: $: alias | grep "^du=" du='du -s * 2>/dev/null | awk '\''{ printf "%4.2f-KB ==> %s \n", $1/1024 , $2 }'\'' | sort -rn' $: alias | grep "^dutop10=" dutop10='du -s * 2>/dev/null | awk '\''{ printf "%4.2f-KB ==> %s \n", $1/1024 , $2 }'\'' | sort -rn | head... (2 Replies)
Discussion started by: newbie_01
2 Replies

2. Shell Programming and Scripting

For loop in bourne shell is not working

I have a loop with cases I am working on Bourne shell for file in *.${Today}*.csv *.${Today}*.txt\ do case ${file} in sun_detail) do something ;; sum) do something ;; mod) do something ;; *) do something ;; (5 Replies)
Discussion started by: digioleg54
5 Replies

3. Shell Programming and Scripting

Alias not working

I have several shell scripts which contain the nawk command. Here is what i m doing assign the correct value to nawk as nawk is not found on a new systems. Here is what i did. more test.sh ] && alias nawk=/usr/bin/gawk ] && alias nawk=/usr/bin/nawk ] && alias nawk=/usr/bin/awk... (7 Replies)
Discussion started by: mohtashims
7 Replies

4. Solaris

Alias not working

Hi, I'm on Solaris (SunOS wsp2cm01 5.10 Generic_150400-10 sun4v sparc SUNW,Sun-Fire-T200). Trying to set up an alias like below - alias grep="/usr/xpg4/bin/grep"but when I call grep in my command it ignores my alias & uses /usr/bin/grep instead. The problem with /usr/bin/grep is that it doesn't... (24 Replies)
Discussion started by: nexional
24 Replies

5. Red Hat

[SOLVED] How the alias is working?

Iam facing some strange issue with alias. I have an alias file in which i have created lot of aliases as given below. export BUILD_HOME=/apps/psr/build export DB_HOME=/apps/psr/database export LOGS_HOME=/apps/psr/logs export BUILD_TEST=/apps/psr/build_dev/build_test export... (0 Replies)
Discussion started by: Vikram_Tanwar12
0 Replies

6. AIX

Alias Command in Bourne Shell

Hi My Unix sever is AIX 5.3. My Login shell ( using echo $SHELL) is /bin/sh implying it is a Bourne Shell. My Question is that i am still able to use Alias command to create/retrieve aliases. I have read in several sites on Unix online that the Bourne Shell does not support Aliases but... (12 Replies)
Discussion started by: pchegoor
12 Replies

7. Solaris

Alias not working

Hello, I am trying to set an alias in my .kshrc or .profile and when I do it is not setting. If I do it manually it works fine. Is there another file I should put this in? Here is the alias I am using. alias ll='ls -ltr' I am using solaris 9. When I type alias it does not show these... (5 Replies)
Discussion started by: dkranes
5 Replies

8. UNIX for Dummies Questions & Answers

alias not working in scripts

Hi All, PF below details, > cat run.sh #!/usr/bin/ksh alias ll="ls -l" > ./run.sh > ll ksh: ll: not found. Pls help on this? Thanks in Advance, Naga :cool: (2 Replies)
Discussion started by: Nagapandi
2 Replies

9. Shell Programming and Scripting

Bourne: How to invoke an alias from within a shell script

Bourne: How to invoke an alias from within a shell script If I type in the alias in the command line, it runs If I insert that same alias into my shell script and run the shell script, the alias is not invoked. Help please. (2 Replies)
Discussion started by: techshots
2 Replies

10. Shell Programming and Scripting

bourne shell not working

This code has worked for years and still does in my production environment. But it's failing in my development environment now. The cd works but the creation of node1, jnum, and node2 fails. Oddly the output shows a line from from the awk script at the end of the code during the setting of each... (6 Replies)
Discussion started by: gillbates
6 Replies
Login or Register to Ask a Question