![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Confusion about 1>&2 and 2>&1 | navi | Shell Programming and Scripting | 1 | 06-03-2008 07:26 AM |
| 'tr' confusion | Nafanja | UNIX for Dummies Questions & Answers | 2 | 12-05-2007 08:47 PM |
| Sed confusion | alfredo123 | Shell Programming and Scripting | 3 | 11-17-2006 09:16 AM |
| ftp confusion | intern | UNIX for Dummies Questions & Answers | 1 | 06-08-2006 03:20 PM |
| ISO Confusion? | Mr_Pinky | UNIX for Dummies Questions & Answers | 6 | 09-19-2005 03:14 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
=================================================
#!/bin/sh HOST=eux091 if [ -s /etc/maestab ] && grep -q $HOST /etc/maestab then IFS=: grep -v -e "^#" -e "^$" /etc/maestab | grep $HOST | \ read HOST MAESTRO_BIN FLAG MAESTRO_USER echo $MAESTRO_BIN MAESTRO_HOME=`dirname $MAESTRO_BIN` echo $MAESTRO_HOME fi ================================================= here is /etc/maestab eul3p3:/opt/maes3p3/maestro/bin:Y:maes3p3 ================================================== script working fine with HP-UX but not in Linux, can you help me out where I am wrong. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Dirname is part of coreutils Linux package.
Do you have the coreutils installed on your Linux system? Regards |
|
#3
|
|||
|
|||
|
Works for me using ksh on linux - provided you set HOST to a value that is in maestab
|
|
#4
|
||||
|
||||
|
Frank,
dirname works wihout issue. fpm, oops!! sorry, i have copied script from my hp-ux system and maestab from linux system. but actully I am paasing value of $HOST by $1 in my script. pls read HOST=eul3p3 in this case. Thanks. Awadhesh Last edited by Awadhesh; 03-04-2008 at 05:50 PM. Reason: . |
|
#5
|
||||
|
||||
|
A script like:
#! /bin/sh echo hello | read word ; echo word = $word will work on HP-UX but fail on Linux. HP's /bin/sh is a modified version of the real Korn shell. But Linux's /bin/sh is a linked version of bash. The real Korn shell is the only shell that executes the last command of a pipeline in the context of the current shell provided that the last command is a shell built-in. Other shells will fork a new process to handle that "read word". The subprocess will exit and back in the parent, the variable "word" never got a new value. Beware: Linux often has pd-ksh which will behave the same way. |
|
#6
|
||||
|
||||
|
thanks, u always come with a torch.
pd-ksh is there, but i really dont know how to use it in script. [root@eul3p3 tmp]# rpm -qa|grep -i pdksh pdksh-5.2.14-30.3 [root@eul3p3 tmp]# Awadhesh |
|
#7
|
||||
|
||||
|
Quote:
#! /usr/bin/ksh on Linux to invoke pd-ksh. I believe that the real ksh is available for Linux, but I don't know how you get it. You need to stop doing some-command | read this that to get your script to work with bash or pd-ksh. If you can't think of anything else, some-command > tempfile read this that < tempfile rm tempfile should do it. |
||||
| Google The UNIX and Linux Forums |