using case to do this might be a bad idea?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using case to do this might be a bad idea?
# 8  
Old 04-06-2007
I missed the errors on the upload of other two files. Here they are.
ok That was output, this is the script. I had to take the "." off of the fileneme of my input file, windoze made me do it.
# 9  
Old 04-06-2007
I found the problem Something is wrong with my typeset statements.
I took them out. The other poster, cfajohnson suggested using the formatting capabilities of printf. I need to learn how to do that.
Thanks Perderabo and cfajohnson and mukundranjan.

SkyyBugg

Update. More specifically it was I believe the typeset commands for pflag and oflag and rflag that were causing the problem.

Thanks. I will get fancy with printf and also get fancy with case.
SB

Last edited by Skyybugg; 04-06-2007 at 02:32 PM..
# 10  
Old 04-06-2007
Quote:
Originally Posted by Skyybugg
I missed the errors on the upload of other two files. Here they are.
ok That was output, this is the script. I had to take the "." off of the fileneme of my input file, windoze made me do it.

Using Windows may be the cause of some of your problems. The files you uploaded have carriage returns that can break scripts, both in the script itself and in the data file.

The script you attached bears little resemblance to the scripts you posted earlier. What is the problem with the script you attached?

# 11  
Old 04-06-2007
CFJ
Thanks for your suggestions!
when I posted the script I said it was a snippet. I thought that the problem was in the snippet. Also I did not want to overwelm any one with my excessive and incomplete documentation.
I only used windows to post the script,output file, input file to this forum.
Thanks to you I decided to focus on the typeset statements.
I found the problem and it was my use of typeset, as I said in my later post, which perhaps you have not read yet.
# 12  
Old 04-06-2007
Quote:
Originally Posted by Skyybugg
I found the problem Something is wrong with my typeset statements.
...
Update. More specifically it was I believe the typeset commands for pflag and oflag and rflag that were causing the problem.

Thanks. I will get fancy with printf and also get fancy with case.

I should have realized what the typeset commands were doing. It's a good example of why you shouldn't use them. Even so, you could have taken that into account in your case statement:

Code:
case $oflag in
    o*) TYPEO="Orders" ;;
esac

Or:

Code:
case $oflag in
    o\  ) TYPEO="Orders" ;;
esac

This printf command should give you what you want; it may need tweaking:

Code:
printf "%-4s%-36s%-9s%-16s%-10s%-2s%-2s%-2s%-10s%-6s\n" "$no" \
             "$NM_SERVER" "$TYPEP" "$TYPER" "$TYPEO" "$pflag" "$rflag" \
             "$oflag" "$NODE_NAME" "$DOMAIN" \

# 13  
Old 04-06-2007
CFAJ,

You are too gereous, writing that code!
Fantastic observations. There is more than one way to write it and more than one way to fix it! I will play around with the case and printf code just to learn it.

What I want to do is to use this scripting more and more so that I can quickly make observations like that. Push out code without breaking a sweat like you just did. and Perderabo.

I sweat over this stuff, but if I use it more, I should improve.
When we add new printers, some processes have to be recycled in the application. I wrote a script long ago to do this, but I have to edit it from one application domain to the next. I want to build these data files and set them to readonly permission so no one will delete them.

My next job is to write one to add the printer wrapping ksh around AIX smitt.

Well I probably in TMI territory now!

Thanks again!
SkyyBugg
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Why I get bad bad substitution when using eval?

Why I get bad replace when using eval? $ map0=( "0" "0000" "0") $ i=0 $ eval echo \${map$i} 0000 $ a=`eval echo \${map$i}` !!!error happens!!! bash: ${map$i}: bad substitution How to resolve it ? Thanks! (5 Replies)
Discussion started by: 915086731
5 Replies

2. Red Hat

Is overlapping two RAID5 arrays on same drives a bad idea ??

is placing two RAID5 arrays on disk as shown below Is advisable? Will this create performance problems? sda-(500GB) sdb-(1TB) sdc-(1TB) sdd-(1TB) (250MB)----------(250MB) ---------unused------------unused------->(/dev/md0) RAID1 ... (6 Replies)
Discussion started by: Saed
6 Replies

3. OS X (Apple)

Deleting a recursive symbolic link was a very bad idea

Well i was tidying up some files in a very important directory on our development server and somehow some plank had put a recursive sybmolic link in it. Which I the even bigger plank tried to delete from my FTP client. My FTP client then thought it would be OK to delete not only the sybmolic link... (0 Replies)
Discussion started by: timgolding
0 Replies

4. Shell Programming and Scripting

case loop... repeat on bad input?

I'm trying to get a case statement to start over if an undefined option is selected... But I am ata loss on how to actually do it. Here is a quick example of what I have. Echo "1) do this/n 2) Do that/n 3) Quit/n Make a selection/n" Read answer Case answer in 1) Dothid;; 2) Dothat;;... (3 Replies)
Discussion started by: trey85stang
3 Replies

5. Shell Programming and Scripting

Script needed to select and delete lower case and mixed case records

HELLO ALL, URGENTLY NEEDED A SCRIPT TO SELECT AND DELETE LOWER AND MIXED CASE RECORDS FROM A COLUMN IN A TABLE. FOR EXAMPLE : Table name is EMPLOYEE and the column name is CITY and the CITY column records will be: Newyork washington ... (1 Reply)
Discussion started by: abhilash mn
1 Replies

6. UNIX for Dummies Questions & Answers

Why is it Bad Idea to insert "." (Dot) to PATH ?

I was told that it's a Bad Idea (especially for root ) to Add To the Variable $PATH in unix the ":." (dot), In order to execute programs in my current directory without typing ./program For example: PATH=$PATH:$HOME/bin:. Does someone know why is it a Bad Idea? (2 Replies)
Discussion started by: amitbern
2 Replies

7. Shell Programming and Scripting

Limitations of awk? Good idea? Bad idea?

Keeping in mind that I'm relatively comfortable with programming in general but very new to unix and korn/bourne shell scripts.. I'm using awk on a CSV file, and then performing calculations and operations on specific fields within specific records. The CSV file I'm working with has about 600... (2 Replies)
Discussion started by: yongho
2 Replies

8. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies
Login or Register to Ask a Question