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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Read a "Tape" File with no extension, in Windows buccacom UNIX for Dummies Questions & Answers 1 02-13-2009 03:35 AM
read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell wiseguy Shell Programming and Scripting 9 01-28-2009 01:20 PM
script to read a line with spaces bet " " and write to a file perlamohan Shell Programming and Scripting 3 11-12-2008 04:27 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
how to request a "read" or "delivered" receipt for mails plelie2 Shell Programming and Scripting 1 08-06-2002 04:26 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-01-2009
potro's Avatar
potro potro is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 61
Solaris "read -e"

Hi,

Why does this piece of script work on a Solaris 10 test.sh script but if I include it in the request script of packaging generates errors?


Code:
        
until [ -n "$CONFIGCACHE" ] && [ -n "$prompt" ] && [ -z `echo $CONFIGCACHE | /usr/xpg4/bin/sed -e 's/[YN]//g' ` ]
        do
                echo -n "Do you want to configure Cache Manager? [Y/N] "
                read -e -n 1 CONFIGCACHE
                echo ""
                prompt=1
        done

In the request script it stops at read -e:
-n Do you want to configure Cache Manager? [Y/N]
/var/tmp//installe5aOBQ/checkinstallh5aOBQ: -e: is not an identifier
pkgadd: ERROR: request script did not complete successfully


If I replace "read -e -n 1" with simple read I get
/var/tmp//install0UaOMQ/checkinstall3UaOMQ: test: argument expected
pkgadd: ERROR: request script did not complete successfully


Thanks,
Bianca

Last edited by potro; 04-01-2009 at 10:47 AM..
  #2 (permalink)  
Old 04-01-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380

That must be run by bash.

It's a horrible piece of code that would be better written, also for bash, as:


Code:
printf "Do you want to configure Cache Manager? [Y/N] "
while :
do
  read -sn1  CONFIGCACHE
  case $CONFIGCACHE in
    [YNyn]) break ;;
  esac
done
echo

  #3 (permalink)  
Old 04-02-2009
potro's Avatar
potro potro is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 61
For this I get

Do you want to configure Cache Manager? [Y/N] /var/tmp//installltaiLW/checkinstallotaiLW: -sn1: is not an identifier
pkgadd: ERROR: request script did not complete successfully

Why don't the read parameters work properly ? I have same with read -e , read -n 1, etc.

Quote:
Originally Posted by cfajohnson View Post

That must be run by bash.

It's a horrible piece of code that would be better written, also for bash, as:


Code:
printf "Do you want to configure Cache Manager? [Y/N] "
while :
do
  read -sn1  CONFIGCACHE
  case $CONFIGCACHE in
    [YNyn]) break ;;
  esac
done
echo

  #4 (permalink)  
Old 04-02-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380
Quote:
Originally Posted by potro View Post
Why don't the read parameters work properly ? I have same with read -e , read -n 1, etc.

You must run it with bash; no other shell will work for that code.
  #5 (permalink)  
Old 04-02-2009
potro's Avatar
potro potro is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 61
I set #!/bin/bash in the scripts.

In a separate script it works .. and in the request script doesn't work that's why is so frustrating.

Quote:
Originally Posted by cfajohnson View Post

You must run it with bash; no other shell will work for that code.
  #6 (permalink)  
Old 04-02-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380
Quote:
Originally Posted by potro View Post
I set #!/bin/bash in the scripts.

In a separate script it works .. and in the request script doesn't work that's why is so frustrating.

What command line do you use to run it?

And please post the entire script that contains it.

And post the output of:


Code:
/bin/bash --version

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0