Problem outputting increment


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem outputting increment
# 1  
Old 05-22-2010
Problem outputting increment

With this script the output to the terminal does not increment. Can anyone tell me what I need to do to get this to increment output to the terminal?

Here is the output
Code:
mpath major,minor number 
ls: /dev/mapper/mpathp1: No such file or directory 
raw device output 
253,44 
echo  raw device output 
sudo raw -q /dev/raw/raw

Here is the script

Code:
#!/bin/bash 
        echo  "**** To terminate at any point press [CTRL + C] ****" 
 
        read -p " What is the beggining mpath Number: " CURR_MP 
        read -p " What is the ending mpath Number: " END_MP 
 
 
#       read -p " What is the begin mpath number: " NUM 
 
        echo -e "\n" 
 
if [ "$#" -eq 2 ]; then 
        # mpath info supplied from command line 
        CURR_MP=$1 
        END_MP=$2 
fi 
 
 
while [ $CURR_MP -le $END_MP ]; 
do 
echo " " 
  perl -ne '/\bmpath${num}\b/ and print' multipath 
echo mpath${num} major,minor number 
ls -la /dev/mapper/mpath${num}p1 | awk '{print $5.$6 }' 
echo  raw device output 
sudo raw -q /dev/raw/raw22 | awk '{ print $5 $7}' 
 
   echo echo  raw device output  
   echo sudo raw -q /dev/raw/raw${num}   
   echo $MPATH 
 
   CURR_MP=$((CURR_MP+1)) 
   NUM=$((NUM+1)) 
done 
 
echo  -e "\n"


Last edited by Scott; 05-22-2010 at 02:19 PM.. Reason: Code tags, please...
# 2  
Old 05-22-2010
Try
Code:
CURR_MP=$(($CURR_MP+1)) 
NUM=$(($NUM+1))

Besides I think you will have to replace all ${num} with ${NUM}
And probably you will also have to uncomment that read...NUM line.

Last edited by pseudocoder; 05-22-2010 at 02:00 PM..
# 3  
Old 05-22-2010
I also am looking for a way to execute this command but the num variable does not get passed example

Code:
VAR=` sudo raw -q /dev/raw/raw${num}`

echo $VAR



does not print out the contents of $VAR

What am i doing wrong here?

Last edited by Scott; 05-22-2010 at 02:21 PM.. Reason: Code tags
# 4  
Old 05-22-2010
Did you try that command in shell of from script?
Did you set the num variable before running that command?
Note that there is difference between num and NUM.
First make sure that the sudo... command alone prints some output, then set the variable VAR.
# 5  
Old 05-22-2010
sudo command output

Yes i tried this command from the shell and it does work, but not in the script.
Thanks for this tip Now that i reset num to NUM that portion works.


here is the shell output.
Code:
sudo raw -q /dev/raw/raw1 
/dev/raw/raw1:  bound to major 253, minor 30

here is my latest attempt with "` `"
Code:
VAR = "`sudo raw -q /dev/raw/raw${NUM}`" 
echo $VAR

no luck
Moderator's Comments:
Mod Comment Please use code tags

Last edited by Scott; 05-22-2010 at 02:34 PM.. Reason: Code tags
# 6  
Old 05-22-2010
Quote:
Originally Posted by bash_in_my_head
Code:
VAR = "`sudo raw -q /dev/raw/raw${NUM}`" 
echo $VAR

Try without quotes, but keep backticks, and avoid whitespaces between VAR and = and between = and the first backtick, like so:
Code:
VAR=`sudo raw -q /dev/raw/raw${NUM}`

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Outputting colours in HP-UX scripts

Hi all, This is my first ever posting, so please be gentle with me :) I'm trying to write a script in HP-UX which outputs text in different colours, but although I can get the script to output different colours to the screen, I can't get it to write different colours to a file. Take the... (4 Replies)
Discussion started by: neilharvey
4 Replies

2. Shell Programming and Scripting

awk not outputting properly

Hi Everyone, Long time lurker here. I have a project of bringing every one of our data centers to a newly enforced company standard. Standard naming conventions, domain migrations, etc. So, the people who are setting the standards are providing me with a CSV file. Column 1 has the old... (23 Replies)
Discussion started by: Zaphod_B
23 Replies

3. UNIX for Dummies Questions & Answers

outputting set -x to file

I need to enable set -x in my croned script as at times the script is not returning all data that it should be. This only happens intermittently and as such I would like a means of being able to check what goes wrong. My question is how to output the debug of set -x to file? (1 Reply)
Discussion started by: rob171171
1 Replies

4. Homework & Coursework Questions

Outputting variables on a line

Stuck on formatting an output. I want to list 6-99 on the screen, looking something like this: 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 and so on down to 6. So far I am only able to print one value per line. This is what I have I have defined x as integer x=99... (2 Replies)
Discussion started by: huckknows
2 Replies

5. Shell Programming and Scripting

Problem with reading file line-by-line, and outputting to a new file

Hi everyone. I realise this is probably a bit of a noob question, but I'm actually a C# developer working on a legacy system, and can't remember much unix. I want to read from a pipe-delimeted file like formatted thusly: idno|PRODUCT|Name|street town postcode|etc|etc|etc|etc... (4 Replies)
Discussion started by: Darkness Fish
4 Replies

6. UNIX for Dummies Questions & Answers

getting input, then outputting it

Hi! I am a newbie to Unix. I was writing a little game program for fun when thought of an idea to allow data to be saved. I knew to take all of the Predefined variables and put them into a separate file, then including the file in the program. But I am having trouble making it so that the user... (0 Replies)
Discussion started by: signebedi
0 Replies

7. Shell Programming and Scripting

Outputting to table

I have information in a file called HITS. This file has been populated by the user entering search criteria. the HITS file contains information: filname.hits: 123.33.345.66 Fri Nov 26 11.45.56.43 GMT 2006 at the moment i am just displayin the information using cat HITS. ... (3 Replies)
Discussion started by: amatuer_lee_3
3 Replies

8. Shell Programming and Scripting

Outputting from two input files.

Ok, lets suppose I have two files like so: file1 John 5441223 Sandy 113446 Jill 489799 file2 Sandy Tuesday Jill Friday John Monday Is it possible to match records from these two files and output them into one output file? For example, lets suppose I want to output like this: ... (5 Replies)
Discussion started by: Liguidsoul
5 Replies

9. Shell Programming and Scripting

Problem with outputting multiple lines

Dear Gurus, I have this output file: F1BDEV13 NTIAF101 2006/09/21 14:54:51 14:55:29 1 0560-0570 LAN F1BDEV14 NTIAF101 2006/09/21 14:55:30 14:55:49 1 0000-0000 LAN F1FSP001 NTIAF101 2006/09/21 14:55:51 14:55:53 1 0000-0000 LAN F1NSP001 ... (6 Replies)
Discussion started by: lweegp
6 Replies

10. UNIX for Dummies Questions & Answers

counter / increment problem within echo stmt

Simple script trying to increment a counter within an echo statement never gets past 1 - PLEASE HELP! Thanks. ~~~~~~~~~~~ #!/bin/sh stepup() { STEP=`expr $STEP + 1` echo $STEP } # # Initialize variables # STEP=0 echo "Counter Value: `stepup`" echo "Counter Value:... (2 Replies)
Discussion started by: blaze
2 Replies
Login or Register to Ask a Question