Shell running setup in Korn ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell running setup in Korn ?
# 1  
Old 08-10-2006
Shell running setup in Korn ?

I am starting to code a few ideas of customization and tasks improvements on the office UNIX machine. My first script (see below) only contains ALIAS commands. But for some reason, when I execute it, the alias are not executed. I suspect it is because of the "#!/bin/ksh" not being recognized or something.

Unix machine is :
* Operating system ..: AIX (64Bit)
* Version / release .: 5.2

using Korn shell


My simple script is :
#!/bin/ksh
#set -x
#
#--------------------------------
# Alias Script
# created on : Aug-9, 2006
# created by :
# modified on:
#
# description : simply alias commands that I
# need for my work to make it easier
#---------------------------------------

alias goto_ae='cd /usr/local/Tivoli/custom/policy'
alias ll='ls -al'

>ls -al
-rwx------ 1 cacv548h tivadm 333 Aug 9 20:46 MyAlias.sh

When I execute it ("sh MyAlias.sh"). It ends without any messages nor problems. But when I execute either new alias, they are not recognized. If I define them on the command line the same way they are in my script, it works.

I tried accessing "man alias" but just about every UNIX commands aren't defined in this system's man.
# 2  
Old 08-10-2006
To execute your script in your current environment use ". MyAlias.sh" not "sh MyAlias.sh".

Both "." and "alias" are shell built-ins, so do not have man pages. Take a look at man ksh instead.
# 3  
Old 08-14-2006
In trying to find the Korn version, I tried these 2 ways found in another thread. Both didn't give me an answer.
>print ${.sh.version}
ksh: ${.sh.version}: 0403-011 The specified substitution is not valid for this command.
>what /bin/ksh | grep Version
>

At logon time I get this as the possible O/S version ?
* Operating system ..: AIX (64Bit)
* Version / release .: 5.2

Accessing the manual on anything is not helpfull as nothing seams to be defined in 'man'.
>man ksh
Manual entry for ksh not found or not installed.
>man ls
Manual entry for ls not found or not installed.
>man ps
Manual entry for ps not found or not installed.
>man cd
Manual entry for cd not found or not installed.
>man
Usage: man [[[-ct] [section]] | [-f | -k]] [-M path] [-r] name...


If I do like you said, I get an error :

>. MyAlias.sh
ksh: MyAlias.sh: not found


I found another script who's first line is '#/bin/ksh' and not '#!/bin/ksh' but using either method simply doesn't work with my script :
>./MyAlias.sh
>ll
ksh: ll: not found
>. MyAlias.sh
ksh: MyAlias.sh: not found

That other script I mentioned actualy works as I ran it last week. Could it be that the problem is isolated to the ALIAS command in scripts ?


In finding other shells I have access to :
>ls /bin/*sh*
...
/bin/bsh
/bin/chsh
/bin/csh
/bin/ksh
/bin/ksh93
...

in /etc/passwd, my ID is there with '/usr/bin/ksh' at the end. So I assume, at logon, I fall into Korn shell ?


Assuming the problem is isolated to ALIAS commands in a shell script, I modified my script to :
#!/bin/ksh
#set -x
#
#--------------------------------
# Alias Script
# created on : Aug-9, 2006
# created by : fapicard
# modified on:
#
# description : simply alias commands that I
# need for my work to make it easier
#---------------------------------------
echo "before alias"
alias goto_ae='cd /usr/local/Tivoli/custom/policy'
alias ll='ls -al'
echo "after alias"

>./MyAlias.sh
before alias
after alias


I executed it and got the echo printouts. So there is a problem with the ALIAS but why ?
# 4  
Old 08-14-2006
Code:
. ./MyAlias.sh

# 5  
Old 08-14-2006
It works !


but why would some script have #/bin/ksh instead of #!/bin/ksh ?
having such a difference would influence how the scripts are being called ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Korn Shell script in stopped state while running in background

Hi, I want to run a shell script in background . but its going to stopped state $ ksh cat_Duplicate_Records_Removal.ksh & 8975 $ + Stopped (tty output) ksh cat_Duplicate_Records_Removal.ksh & why is this happening? Also could anyone please tell me what is a stopped... (12 Replies)
Discussion started by: TomG
12 Replies

2. Red Hat

Trying to get mailx setup and running

Ive kind of been left on my own to get things working on a production linux box. Im happy because it gives me some true admin experience. But theres alot I dont know ... Im trying to get mailx running. I can create an email, but it never gets delivered to my external email account. I am... (2 Replies)
Discussion started by: popeye
2 Replies

3. Shell Programming and Scripting

running a script in korn shell

I'm learning bash and have discovered that the shell can only work with integers and not decimals. I'd like to run my scripts in korn to account for this, but just now, when I tried to run my script, I got an error message that said 'no such file or directory,' even though when I'm in the shell... (3 Replies)
Discussion started by: Straitsfan
3 Replies

4. Shell Programming and Scripting

How to activate Korn Shell functionnalities in Bourne Shell

Hi All I have writing a Korn Shell script to execute it on many of our servers. But some servers don't have Korn Shell installed, they use Borne Shell. Some operations like calculation don't work : cat ${file1} | tail -$((${num1}-${num2})) > ${file2} Is it possible to activate Korn Shell... (3 Replies)
Discussion started by: madmat
3 Replies

5. Solaris

Running setup on a new server

I have a newly built Solaris 10 server that I want to install Sun One web server. After building the server I use FTP to copy over the web server installation files into a directory I created (/usr/local/software/JES/6.1sp8). I run ./setup and get this. bash: ./setup: Permission denied I... (7 Replies)
Discussion started by: gsander
7 Replies

6. UNIX for Dummies Questions & Answers

running script with korn shell

How would i instruct the current shell to run the current script using the korn shell? (1 Reply)
Discussion started by: JamieMurry
1 Replies

7. Shell Programming and Scripting

Running a Java Programm with a (korn)shell-script

hey everyone, For my studies i had to write a javaprogram which reads 2 integers from the keyboard and then using the basic operations(addition, division etc) with them. so far no problem. but now i gotta make a shell-script which: runs the program(compiled with javac) #!bin/ksh java... (1 Reply)
Discussion started by: simlmf
1 Replies

8. Shell Programming and Scripting

Korn Shell script not running

I am sorry, this is really trivial, yet I am not able to understand what the problem is! I am using korn shell and running this script #!/bin/ksh keep=3 while ; do echo $keep keep=$(($keep-1)) done I am getting this error: `keep=$' unexpected I am not able to understand it because ... (1 Reply)
Discussion started by: Asty
1 Replies

9. Shell Programming and Scripting

how to convert from korn shell to normal shell with this code?

well i have this code here..and it works fine in kornshell.. #!/bin/ksh home=c:/..../ input=$1 sed '1,3d' $input > $1.out line="" cat $1.out | while read a do line="$line $a" done echo $line > $1 rm $1.out however...now i want it just in normal sh mode..how to convert this?... (21 Replies)
Discussion started by: forevercalz
21 Replies

10. Shell Programming and Scripting

checking for a running process from korn cron

cron starts a job every 10 minutes via a korn shell - I need to determine if the previous process is still running before I allow the new process to start - HELP I've tried ps -ef, etc but I have seen many situation where it says that the is running when it is not - any ideas on how to absolutely... (2 Replies)
Discussion started by: jph
2 Replies
Login or Register to Ask a Question