Error "Cat Error: Bad Address "


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error "Cat Error: Bad Address "
# 1  
Old 04-01-2002
Error "Cat Error: Bad Address "

Hi
I get an Error when i am trying to edit a file thru shell script.

ERROR IS "cat: write error: Bad address."

I don't get this error everytime i run the shell script.
Any idea ??

Here is the piece of code:

echo "Attempting to edit ${ProbeRuleFile}"
if [ -f ${ProbeRuleFile} ]
then
cp ${ProbeRuleFile} ${ProbeRuleFile}.${datestamp}
sleep 5

INSERT13="include \"\/opt\/Omnibus\/probes\/solaris2\/mform_fdf.rules\"!!#!# Here we temporarily
set @Agent, for the above cases"
cat ${ProbeRuleFile} | sed "s/# Here we temporarily.*/${INSERT13}/" | tr '!' '\n' > ${ProbeRuleF
ile}

echo "Setting Events Agent"
sleep 5
INSERT14="case \"formation\":! @Agent = \$agent! case \"unix\":"
cat ${ProbeRuleFile} | sed "s/case \"unix\":.*/${INSERT14}/" | tr '!' '\n' > ${ProbeRuleFile}

TEMP_LINE_NU=`grep -n "Details, \"\[0-9\]" ${ProbeRuleFile} | awk -F: '{print $1}'`
((TEMP_LINE_NU = $TEMP_LINE_NU + 1))
echo "line no. ${TEMP_LINE_NU}"
cat ${ProbeRuleFile} | sed "${TEMP_LINE_NU}s/discard/\#discard/" | tr '!' '\n' > ${ProbeRuleFile
}
echo "done \n"
else
echo "File: ${ProbeRuleFile} not found!!!"
#exit
fi
# 2  
Old 04-03-2002
Looks to me (at a glance) like it might have something to do with the way you are manipulating the file then directing it to it's own name.

cat ${ProbeRuleFile} | sed "s/# Here we temporarily.*/${INSERT13}/" | tr '!' '\n' > ${ProbeRuleFile}

Try this line of code by itself - and see what happens. You'll probably end up with an empty file of ${ProbeRuleFile}

This could then ruin the subsequent commands that use this file.

If you want to edit a file (as you are doing with the sed commands) you must rename the file to something else - then you can rename if back to the original.

To verify where the error is occuring - try bits of the script at a time i.e. comment out or remove subsequent steps. Or try the commands directly outside of the script (replacing the variables with the actual names).
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

/var/log/messages error "kernel: RPC: bad TCP reclen"

Hi, I am seeing the following errors in my environment, not sure why is it happening, any ideas? Thanks. kernel: RPC: bad TCP reclen 0x73746174 (non-terminal ) Dec 17 02:14:48 kernel: RPC: bad TCP reclen 0x63480000 (large) Dec 17 02:14:48 kernel: RPC: bad TCP reclen 0x633f0000 (large) Dec... (5 Replies)
Discussion started by: amarlinux
5 Replies

2. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

3. UNIX for Dummies Questions & Answers

> 5 ")syntax error: operand expected (error token is " error

im kinda new to shell scripting so i need some help i try to run this script and get the error code > 5 ")syntax error: operand expected (error token is " the code for the script is #!/bin/sh # # script to see if the given value is correct # # Define errors ER_AF=86 # Var is... (4 Replies)
Discussion started by: metal005
4 Replies

4. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

5. Shell Programming and Scripting

Error-- : " bad string"

Hi All, wen i am running a script . its giveing the below error and hanging there Bad string ******************* Please enter the following details one by one --------------------------------------------- ... (6 Replies)
Discussion started by: manoj_dahiya22
6 Replies

6. Shell Programming and Scripting

read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Hallo, i need a Prompting read in my script: read -p "Enter your command: " command But i always get this Error: -p: is not an identifier When I run these in c-shell i get this error /usr/bin/read: read: bad option(s) How can I use a Prompt in the read command? (9 Replies)
Discussion started by: wiseguy
9 Replies

7. HP-UX

ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

Hi people! I've got this own library: -------------------------------------------- Personal.h -------------------------------------------- #ifdef __cplusplus extern "C" { #endif #include <stdio.h> #include <stdarg.h> #include <string.h> ... (0 Replies)
Discussion started by: donatoll
0 Replies

8. Solaris

sendmail "root... User address required." error

I'm running sendmail (8.13.8+Sun/8.13.8/Submit) solaris 10. When I send mail to root at the command line (whether I use a full-qualified address or just root), I get the error message root... User address required. Sending mail to root (either at the command line or in a cron job),... (10 Replies)
Discussion started by: csgonan
10 Replies

9. Shell Programming and Scripting

"syntax error at line 21 :'done' unexpected." error message"

I am trying to run the script bellow but its given me "syntax error at line 20 :'done' unexpected." error message" can someone check to see if the script is ok? and correct me pls. Today is my first day with scripting. Gurus should pls help out #!/bin/ksh # Purpose: Check to see if file... (3 Replies)
Discussion started by: ibroxy
3 Replies
Login or Register to Ask a Question