1753428 Members
5024 Online
108793 Solutions
New Discussion юеВ

Re: Script error.

 
SOLVED
Go to solution
Adam W.
Valued Contributor

Script error.

Guru's I have attached a script that several of you helped me with, but I am getting an error on one of my servers whenever it runs. I can't figure out the issue. Below is the error I get:

sed: Function s/ * cannot be parsed.
sed: Function s/ cannot be parsed.
/usr/local/bin/filesystemcheck.sh[66]: emailfile: not found.
"emailfile" [New file]

*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
/usr/local/bin/filesystemcheck.sh



Can any of you give me an idea of what is wrong? It runs smoothly on all of my other servers, and all of my server are the same software. HP-UX 11.11 all gold packs applied.
There are two types of people in the world, Marines and those who wish they were.
13 REPLIES 13
Patrick Wallek
Honored Contributor

Re: Script error.

On the problematic server, add the following to the top of your script:

#!/usr/bin/sh -x

Then run it again, capture the output and attach it here.

The '-x' turns on 'debug mode' for the shell.
James R. Ferguson
Acclaimed Contributor

Re: Script error.

Hi:

I see two things based on your attachment.

1. Always begin your script's with a shebang line:

#!/usr/bin/sh

...or whatever interpreter is appropriate.

2. You are missing a 'done' as the last line to match the 'do' loop.

Regards!

...JRF...
Ivan Krastev
Honored Contributor
Solution

Re: Script error.

On lines 42-44 you have CR/LF which breaks line to 2 lines.

exceeded=`bdf | sed '/^Filesystem/d' | head -$count | tail -1 | sed 's/ *
/:/g' | cut -d ":" -f5`

Try to move it to 1 line:
exceeded=`bdf | sed '/^Filesystem/d' |head -$count | tail -1 | sed 's/ * /:/g' | cut -d ":" -f5`


Check all lines for such errors.
regards,
ivan
Adam W.
Valued Contributor

Re: Script error.

There is a shebang line. I forgot to copy it.

Missing a done? If I was missing a done, the script wouldn't work on my other servers. Right?

Crap there is a LB on those lines. I am retarded I swear! BRB fellas.
There are two types of people in the world, Marines and those who wish they were.
Adam W.
Valued Contributor

Re: Script error.

Attached is the debug.
There are two types of people in the world, Marines and those who wish they were.
James R. Ferguson
Acclaimed Contributor

Re: Script error.

Hi (again):

Ivan spotted a very big problem unless it is only a manifestion of posting your script here. That is, you can't split commands across lines. You don't need to confine your line length to a terminal line width although this makes readability, printing and editting easier.

If you want to "split" lines, use the line continuation character. For example at the line 42 Ivan cited, you could break the line into three lines like:

exceeded=`bdf | sed '/^Filesystem/d' | \
head -$count | tail -1 | \
sed 's/ */:/g' | cut -d ":" -f5`

...NOTICE that there are no trailing spaces after the continuation character (\) either.

Regards!

...JRF...
Patrick Wallek
Honored Contributor

Re: Script error.

Perhaps I'm blind, but I didn't see an error in the debug output you posted.
Adam W.
Valued Contributor

Re: Script error.

Very good. No trailing spaces..... got it.

James/Ivan/Patrick, Always a pleasure and you all always know what needs done. One day I will ahve this scripting thing down.
There are two types of people in the world, Marines and those who wish they were.
Adam W.
Valued Contributor

Re: Script error.

Patrick, Ivan was correct in the line break. I made (yet another) rookie error that is so common with me. Thanks to you all.
There are two types of people in the world, Marines and those who wish they were.