Converting Script from Linux (GNU) Bash 4 to Solaris Bash 2.05 - Any cheat sheet?
Ok, i'm trying to port bash script from my Linux system to Solaris. The end user "doesn't like linux" or apparently upgrading utilities. He has a Solaris 9 system with bash 2.05.
I'm also having a weird issue where the commands are working on the command line but not in the scripts even though the #! line is pointing to the same bash returned by $0 (i don't trust echo $SHELL). I'm sure this is probably a head slap issue that i'm just missing something easy but any help would be appreciated. I have a large script (kind of grew from five or six individual scripts) in bash. I have many commands i'm used to using that are now failing on the solaris test box. Does anyone have or know of a conversion type cheat sheet to help me change things over. So far these are the command giving me fits and making me go through a lot of revisions to find the one that works. If you know any better ways to do this please let me know. Code:
count=`grep -o ":" <<< $testLine| wc -l` |
Quote:
Code:
for i in $(awk 'BEGIN {for(i=0;i<10;i++) print i}');do echo $i;done |
Quote:
|
For Solaris that old, you're probably better off using ksh. I used it for years on Solaris (& HP-UX & Dynix); pretty good.
The ksh built-ins are usually the same, but the version of ksh there is probably more capable (than that version of bash) eg probably handle [[ ]], maybe even (( )) See http://www.kornshell.com/ External cmds like grep and sed are a completely separate qn. The grymoire page may help; it tends to be a bit old school http://www.grymoire.com/Unix/ Have you got or can you get/upgrade the sfw (sun freeware) pkg for that? Has all the GNU version utils. Why don't you try any version of bash you can find on that system ie both $0 and $SHELL; you might be surprised. |
Quote:
Quote:
Quote:
Quote:
Quote:
|
First let me say THANKS for your help. i'm at the head to the wall stage :banghead:
Ok, in order as they came Code:
grep -o Code:
colons=${testline//[!:]/} does not work - bad substitution error Code:
mycounter=$(( mycounter + 1 )) Code:
: $(( mycounter += 1 )) Code:
for i in `seq 8` Code:
i=0 nothing with double (()) is accepted. Code:
grep "^[[:alpha:]]" Code:
NevVal=$(($myval/$myDivisor)) Quote:
Code:
NevVal=$(($myval/$myDivisor)) Code:
#!/usr/bin/bash ## also run /bin/bash Code:
test7.sh: syntax error at line 6: 'NewVal=$' unexpected Code:
echo $SHELL AND A NEW ONE case isn't working as expected, my mini test is as follows Code:
#!/usr/bin/bash Code:
/bin/bash |
I HAVE FOUND one big mistake i've been doing. I've been calling the script from the command line with sh script.sh like i've always done (i guess not). if i just make it executable and rely on the "shebang" a lot of these irritating issues go away. NOT all. the case problem still exists.
Actually the case error was caused by using wc -l (it pads the answer) so switching to a grep -c fixed that. Thanks everyone. |
All times are GMT -5. The time now is 11:22 PM. |