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
Numeric or not? harrisjl Shell Programming and Scripting 3 12-01-2008 12:48 AM
Numeric or not harrisjl Shell Programming and Scripting 1 11-30-2008 11:54 PM
Perl code to differentiate numeric and non-numeric input Raynon Shell Programming and Scripting 11 08-04-2007 11:32 AM
how do I make dynamic parameter names? Or get the value of a parameter evaluated twi Awanka Shell Programming and Scripting 2 04-19-2007 10:37 PM
non-numeric argument TiredOrangeCat UNIX for Dummies Questions & Answers 3 02-13-2007 02:37 AM

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
jack2 jack2 is offline
Banned
  
 

Join Date: Mar 2009
Posts: 47
Under what sh `scaley 27` is a numeric-parameter ?

Hi,

this part of code comes from an example
in dialog utility.
Running it under /sh
the following error is generated

"
Error: Expected a numeric-parameter for --begin.
Use --help to list options.
"
Is this example is 6 years old only, I expect it to work finally.

Jack


ROWS="`cut $tempfile -f1 -d, | cut -f2 -d:`"
COLS="`cut $tempfile -f2 -d,`"
rm $tempfile

# account for widest labels
COLS=`expr $COLS - 30`

# Takes an integer, multiplies it for COLS, divides for 132
scalex() {
echo $[$1*$COLS/132]
}
scaley() {
echo $[$1*$ROWS/60]
}

$DIALOG --backtitle "$TITLE" --no-shadow \
--begin `scaley 27` `scalex 98`
  #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 should run in bash, but I'd fix it so that it will run in any POSIX shellL


Code:
# $tempfile format: ROWS:???,COLS
IFS=:, read x ROWS COLS < "$tempfile"

# account for widest labels
COLS=$(( $COLS - 30 ))

# Takes an integer, multiplies it for COLS, divides for 132
scalex() {
  echo $(( $1 * $COLS / 132 ))
}

scaley() {
  echo $(( $1 * $ROWS / 60 ))
}

  #3 (permalink)  
Old 04-03-2009
jack2 jack2 is offline
Banned
  
 

Join Date: Mar 2009
Posts: 47
Quote:
Originally Posted by cfajohnson View Post

That should run in bash, but I'd fix it so that it will run in any POSIX shellL


Code:
# $tempfile format: ROWS:???,COLS
IFS=:, read x ROWS COLS < "$tempfile"

# account for widest labels
COLS=$(( $COLS - 30 ))

# Takes an integer, multiplies it for COLS, divides for 132
scalex() {
  echo $(( $1 * $COLS / 132 ))
}

scaley() {
  echo $(( $1 * $ROWS / 60 ))
}

Thanks for your kindly reply.
Exactly, examples I test, are 5-10 years old, written for bash.
Successfully I have both shells installed.

Jack
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 07:29 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