The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-04-2008
Awadhesh's Avatar
Registered User
 

Join Date: Jul 2005
Location: Delhi, India
Posts: 92
Lightbulb Confusion about IFS Variable

=================================================
#!/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.
Reply With Quote
Forum Sponsor
  #2  
Old 03-04-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,326
Dirname is part of coreutils Linux package.
Do you have the coreutils installed on your Linux system?

Regards
Reply With Quote
  #3  
Old 03-04-2008
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,061
Works for me using ksh on linux - provided you set HOST to a value that is in maestab
Reply With Quote
  #4  
Old 03-04-2008
Awadhesh's Avatar
Registered User
 

Join Date: Jul 2005
Location: Delhi, India
Posts: 92
Arrow

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: .
Reply With Quote
  #5  
Old 03-04-2008
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
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.
Reply With Quote
  #6  
Old 03-04-2008
Awadhesh's Avatar
Registered User
 

Join Date: Jul 2005
Location: Delhi, India
Posts: 92
Cool Thanks!!

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
Reply With Quote
  #7  
Old 03-05-2008
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
Quote:
Originally Posted by Awadhesh View Post
.
pd-ksh is there, but i really dont know how to use it in script.
Well, considering that pd-ksh will fail in the same manner that bash does, I'm not sure that this is any great loss. But just use
#! /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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0