how do i disable awk retruncode?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how do i disable awk retruncode?
# 1  
Old 01-04-2006
how do i disable awk retruncode?

Hi community,

i am processing some output with awk:

cat initHC2.sap | awk '{ print $0 ~ /^tape_addr*/? gsub(/[",","(",")"]/," ") $1" "$2" ("$4","$3")" : ""}'| sort | tail -2

with gsub, i replace in two lines

tape_address = (/dev/nrmt0h,/dev/nrmt1h)
tape_address_rew = (/dev/rmt0h,/dev/rmt1h)

this : "(" ")" "," with a whitespace to get fields

tape_address = /dev/nrmt0h /dev/nrmt1h
tape_address_rew = /dev/rmt0h /dev/rmt1h

and then i am able to flip the tapes with the fields

it works good, but there is ONE BIG PROBLEM:
The return code given by awk, printed at the beginning of the line!

result is allways this line:

3tape_address = (/dev/nrmt1h,/dev/nrmt0h)
3tape_address_rew = (/dev/rmt1h,/dev/rmt0h)

i need to get rid of the numbers, does anyone know how to do this? i need to turn of awk's return code somehow...

Another problem is how do i manage awk to give no line out if the statement is false?

$0 ~ <pattern>? <then> : <else> }'

I don't want no <else> or if i need to give an else value, what should i write there to get no line printed at all? even "" prints a single line and i hav a lot of annoying empty lines at the end...

regards,markus

Last edited by madx1701; 01-04-2006 at 07:58 AM..
# 2  
Old 01-05-2006
Data

hello there everybody...? does nobody have an idea ..?

-regards, markus
# 3  
Old 01-05-2006
try redirect the error code to dev null

# your_commands 2> /dev/null
# 4  
Old 01-05-2006
hi
i think the problem is with print try removing print statement awk will print by default
and the return value is from gsub

Code:
gsub(regex, str [, target]) N 

Globally substitute str for each match of the regular expression regex in the string target. If target is not supplied, defaults to $0. Return the number of substitutions.

bye

Last edited by vishnu_vaka; 01-05-2006 at 07:31 AM..
# 5  
Old 01-06-2006
Hi there,

removing the print statement caused that awk did not print anything at all, redirection of error code did not succeed either. any other ideas left?

-regards,markus
# 6  
Old 01-06-2006
You could try resetting the Field Seperator, e.g...
Code:
$ cat initHC2.sap
tape_address = (/dev/nrmt0h,/dev/nrmt1h)
tape_address_rew = (/dev/rmt0h,/dev/rmt1h)

$ awk -F '[(,)]' '{printf "%s(%s,%s)\n", $1, $3, $2}' initHC2.sap
tape_address = (/dev/nrmt1h,/dev/nrmt0h)
tape_address_rew = (/dev/rmt1h,/dev/rmt0h)

# 7  
Old 01-10-2006
Hi Ygor,

your command did not work correctly, because somehow, awk put a (,) after each line of the output:

[...]
# NT: "mt -f $ rewind"(,)
rewind = "mt -f $ rew"(,)
(,)
# rewind and set offline command(,)
[...]

however, you have shown me the right way. after some modification, it worked:

awk -F '[,)(]' '{print $0 ~ /^tape_addr*/ ? $1"("$3","$2")\n" : $0}' initHC2.sap | grep ^tape_addr

tape_address = (/dev/nrmt1h,/dev/nrmt0h)
tape_address_rew = (/dev/rmt1h,/dev/rmt0h)

Tanks a lot!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Printer is getting disable...

Dear expert, I have configured the printer on my linux server, Daily its getting disable and user cannot access the printer. Request you to please help me on this, Attached the screen shot. Thank you, Faiz. (2 Replies)
Discussion started by: Mohammed Faiz
2 Replies

2. UNIX for Dummies Questions & Answers

Auditd (How to disable)

I'm running CentOS 5.x and want to disable this daemon as it's crashing my server daily! I didn't install that and don't know why it's started magically for some reason. Please enlighten me to the answer to this question, I've read the man pages on this and found something that stops it... (2 Replies)
Discussion started by: HiphopTech
2 Replies

3. Red Hat

SSL/TLS renegotiation DoS -how to disable? Is it advisable to disable?

Hi all Expertise, I have following issue to solve, SSL / TLS Renegotiation DoS (low) 222.225.12.13 Ease of Exploitation Moderate Port 443/tcp Family Miscellaneous Following is the problem description:------------------ Description The remote service encrypts traffic using TLS / SSL and... (2 Replies)
Discussion started by: manalisharmabe
2 Replies

4. AIX

disable bash

Hi, is there a way to disable bash shell only for specific users? (7 Replies)
Discussion started by: firefox111
7 Replies

5. UNIX for Dummies Questions & Answers

How to disable services ?

I would like to know how would i disable service which helps mounting of removable devices automatically? I dont want to disable mounting but i would like to disable automatic mounting of devices. I would like to do this as security major on one of our production server. (2 Replies)
Discussion started by: pinga123
2 Replies

6. Shell Programming and Scripting

How to disable Enable/Disable Tab Key

Hi All, I have bash script, so what is sintax script in bash for Enable and Disable Tab Key. Thanks for your help.:( Thanks, Rico (1 Reply)
Discussion started by: carnegiex
1 Replies

7. Solaris

How to disable SU right

Anyone know how to disable SU right for a particular user in Solaris 8 (4 Replies)
Discussion started by: civic2005
4 Replies

8. Solaris

disable cd n ls in sftp

how do we disable cd and ls within sftp. I would like to restrict user to a particular directory.(as i cannot use anonymous ftp for some reasons) thanks in advance (0 Replies)
Discussion started by: livemyway
0 Replies

9. UNIX for Dummies Questions & Answers

disable su

i have this unix version "unix v/386" and i want to disable su kindly help me (2 Replies)
Discussion started by: sak900354
2 Replies

10. UNIX for Dummies Questions & Answers

Disable X

Im sure this is somthing easy to do but i just can not figure it out where and how would i take X out of the boot for hp ux 11 i looked in the man's and nothing so maybe sombody could throw me a bone... thanks BB (8 Replies)
Discussion started by: bbutler3295
8 Replies
Login or Register to Ask a Question