Error in script

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2006
Posts: 17
Reputation: rusman is an unknown quantity at this point 
Solved Threads: 0
rusman rusman is offline Offline
Newbie Poster

Error in script

 
0
  #1
Nov 1st, 2007
Hello,

I have a script I've used on pre-Solaris 10 that works just great. Now on a Sol10 box, it is bailing on this line with this error: syntax error at line 27: `|' unexpected
Here's the 'offending' line:
Shell Scripting Syntax (Toggle Plain Text)
  1. creation=`echo $backupid | sed 's/^.*_//'`
I'm a bit confused as to why this isn't working as I've pulled it out of the script and can run it successfully from the command line directly. Any ideas?

As always, thanks for the help!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Error in script

 
0
  #2
Nov 1st, 2007
Hey there,

From the info you've given I wrote this:

#!/bin/ksh

backupid="hi_there"
creation=`echo $backupid | sed 's/^.*_//'`
echo $creation

and ran it. It returned:

_there

Do you have more info on it? What would your backupid variable be set to? We're running Solaris 10 on hardware like V245's, T2000's and X4100's - also some Fujitsu PrimePowers. Also, it might be related to a patch. We're running the recommended patchset from April still.

Thanks,

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Error in script

 
0
  #3
Nov 1st, 2007
Originally Posted by rusman View Post
Hello,

I have a script I've used on pre-Solaris 10 that works just great. Now on a Sol10 box, it is bailing on this line with this error: syntax error at line 27: `|' unexpected
Here's the 'offending' line:
Shell Scripting Syntax (Toggle Plain Text)
  1. creation=`echo $backupid | sed 's/^.*_//'`
I'm a bit confused as to why this isn't working as I've pulled it out of the script and can run it successfully from the command line directly. Any ideas?

As always, thanks for the help!!
It shouldn't really make a difference, but the following change is always worth while, and worth a try:

Shell Scripting Syntax (Toggle Plain Text)
  1. creation=`echo "${backupid}" | sed 's/^.*_//'`

Edit: Since you're using ksh, you may also wish to change "echo" to "print".
Last edited by masijade; Nov 1st, 2007 at 9:12 pm.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum


Views: 951 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Shell Scripting
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC