Different output in AIX and Linux OS


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Different output in AIX and Linux OS
# 1  
Old 03-17-2009
Different output in AIX and Linux OS

Hi All ,

Please help me in understanding why i am getting error for the below script in LINUX, but the same script will work perfectly in AIX unix.

Script Name:try.ksh

#!/bin/ksh

echo "$0 \n"
MYPWD=$(pwd $(dirname $0))
echo " $MYPWD \n"

O/P in LINUX OS:
./try.ksh
./try.ksh[4]: pwd: too many arguments


O/P in AIX OS

./try.ksh
/exec/applis/74epur/current

Thanks In Advance
Sudhir
# 2  
Old 03-17-2009
Is your Korn shell on Linux really Korn? I haven't played with Linux for a while, but the Bourne shell (/bin/sh) used to be a link to Bash - is it still? Is the same true for ksh?

If you want to track the directory the shell is running in, here's my standard code chunk...
Code:
dirname=`dirname $0`
[ "$dirname" = "." ] && dirname=`pwd`

Hopefully this this shell neutral code!Smilie
# 3  
Old 03-17-2009
The problem is not with ksh per se, it is with your code. Passing a command line argument to pwd is invalid.
Code:
MYPWD=$(pwd $(dirname $0))

Here is an example
Code:
$ pwd .
pwd .
ksh: pwd: too many arguments
$

Some shells silently ignore the error
Code:
bash-3.2$ pwd .
/home/fpmurphy
bash-3.2$ pwd /opt
/home/fpmurphy
bash-3.2$

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AIX -/usr/bin/expect shows output Don't know why.

Hi, I have been programming with the expect program for a while now and have create a series of menu driven checks for the operations team. One thing I have noticed is that I call a remote script and pass parameters and this is display on the screen....for example. Within the script ... (0 Replies)
Discussion started by: yakky
0 Replies

2. Infrastructure Monitoring

AIX monitoring tools for graphical output

Hi , I am new for Aix i am using IBM AIX server in our org. I am using tomcat and JDK 1.6 for our own ERP software the data base was stored in another server (windows ) i want to monitor my AIX server with graphical output from another system it is possible please help me, any other... (7 Replies)
Discussion started by: krishna_vnr`
7 Replies

3. Programming

C++: No output for Char* when on AIX. Worked on Linux

Hi All, I have a script (attached) that was working fine on Linux. I compiled it there using g++ CrncyFmt.cpp -o CrncyFmt.o When I ran it there using eg. CrncyFmt.o 2343.565 2 I get as expected: CharOut = " 2,343.57" Now we have moved to our test box which is AIX and I... (11 Replies)
Discussion started by: Leedor
11 Replies

4. Shell Programming and Scripting

AIX to Linux

I am Application Administrator with little bit experience with UNIX , We are changing the OS from AIX to Red hat Linux . Wondering if there anyway how to change the scripts to work on LINUX env and how to start to modify the scripts..Any Suggestions Thanks in Advance (15 Replies)
Discussion started by: tutkiran
15 Replies

5. AIX

Scripting AIX date output !!

Hi, I am writing a korn shell script in AIX. I want to pass the date as a parameter to script and inside it should convert the format to +%a" "%h" "%d" "%Y. For e.g., a parameter passed as "20100301" should be converted to "Mon Mar 01 2010". I can easily do this with AIX "date" option for... (2 Replies)
Discussion started by: shibajighosh
2 Replies

6. AIX

How to mail the output of a command in AIX

Hi, I have mastered how to mail to Windows in AIX. Can anyone tell me how I would mail the output command df -g to an email? I want to set a job in cron to mail df -g as the contents of a mail. Any ideas? Thanks John (4 Replies)
Discussion started by: jfd7000
4 Replies

7. AIX

Aix 5.3 or Linux?

Hey I have an IBM IntelliStation Power 9114 Model 275 1.45GHz Workstation 1-Way 1.45GHz Power4+ Processor (5223) 2GB Memory (4x 512MB Dimms) (4447) and was told that AIX 5.3 works on it, and that there was problems with Linux installs. Can I download AIX 5.3 or do I need to buy... (13 Replies)
Discussion started by: newtoaix
13 Replies

8. UNIX for Dummies Questions & Answers

Capturing output from grpck command on AIX

I'm having trouble capturing output from the following command on AIX: grpck -n ALL > error.out It gives me the results on the screen but my file is blank. I have no trouble capturing output from "ls > ls.out", but doesn't seem to work with the grpck command. Any ideas? Thanks. (2 Replies)
Discussion started by: pdtak
2 Replies

9. AIX

No Graphics Output in pSeries, AIX 5.3

Hi All -- I have an old 7028-6C1 which I'm using to learn AIX. The system didn't include a graphics card, so I connected via the serial port and performed a fresh install of AIX 5L V5.3. Later, I purchased a GXT135P (2849) graphics card, and added it to the system. When I ran diag, I was able... (2 Replies)
Discussion started by: i386tech
2 Replies

10. AIX

PS output truncation in AIX

folks; i need help with a truncation problem in AIX when running "ps" command. when i run ps in SUN, i got the full output but when i run it in AIX the output is truncated. is there any arguments i can pass to give longer output so i can overcome the issue? here's the details:(please note the... (2 Replies)
Discussion started by: moe2266
2 Replies
Login or Register to Ask a Question