Under what sh `scaley 27` is a numeric-parameter ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Under what sh `scaley 27` is a numeric-parameter ?
# 1  
Old 04-01-2009
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  
Old 04-01-2009

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  
Old 04-03-2009
Quote:
Originally Posted by cfajohnson

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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Call Script with Parameter (that has another parameter)

Hi. How do I achieve this sh /EDWH-DMT02/script/MISC/exec_sql.sh "@/EDWH-DMT02/script/others/CSM_CKC/Complete_List.sql ${file_name}" Complete_List.txt The /EDWH-DMT02/script/MISC/exec_sql.sh has two parameters and it's working fine with this sh /EDWH-DMT02/script/MISC/exec_sql.sh... (7 Replies)
Discussion started by: aimy
7 Replies

2. Shell Programming and Scripting

Resolving a parameter which is passed as parameter

Hi, I have the following files. ->cat scr.sh export TMP_DIR=/home/user/folder1 export TMP_DIR_2=/home/user/folder2 while read line do cat "$line" done<file_list.dat ------------------------ -> cat file_list.dat $TMP_DIR/file1.txt $TMP_DIR_2/file2.txt --------------------------- -> cat... (6 Replies)
Discussion started by: barath
6 Replies

3. Shell Programming and Scripting

How to get the parameter value from the parameter file in perl?

hi all, i have a parameter file of following format, i want a method which can get the value of specific parameter. parameter file format: <Parameter Name="FileLocationWindows"> <Description> The directory location of the logger file. ... (1 Reply)
Discussion started by: laxmikant.hcl
1 Replies

4. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

5. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

6. UNIX for Dummies Questions & Answers

Find and Replace random numeric value with non-numeric value

Can someone tell me how to change the first column in a very large 17k line file from a random 10 digit numeric value to a non numeric value. The format of lines in the file is: 1702938475,SNU022,201004 the first 10 numbers always begin with 170 (6 Replies)
Discussion started by: Bahf1s
6 Replies

7. Shell Programming and Scripting

Numeric or not?

Is there an easy way using a command or other routine for testing whether an argument on the command line is numeric? Just want to validate... I ran a search and didn't find a similar question.... Thx (3 Replies)
Discussion started by: harrisjl
3 Replies

8. Shell Programming and Scripting

Numeric or not

Is there a simple way of determining whether a command line arguement is numeric or not?? I tried a search and didn't find anything similar... This is the 2nd time I've made this post.... It didn't appear that the first one showed up ?? Sorry if this is a duplicate... (1 Reply)
Discussion started by: harrisjl
1 Replies

9. Shell Programming and Scripting

Perl code to differentiate numeric and non-numeric input

Hi All, Is there any code in Perl which can differentiate between numeric and non-numeric input? (11 Replies)
Discussion started by: Raynon
11 Replies

10. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies
Login or Register to Ask a Question