LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-05-2008, 01:06 PM   #1
jxrod2000
Member
 
Registered: Apr 2006
Location: MA, USA
Distribution: OpenSuse 11
Posts: 34

Rep: Reputation: 15
Bash behaving differently


Hello,

This is strange and I have no clue why:

On my desktop system (opensuse 11) the following script runs without an issue on bash 3.2.39

echo " " >> $ilog
echo "==> Copying $apps directory " >> $ilog
let "ix=0"
while [ "$ix" -lt 5 ]
do
rsync $opt $apps $rserver$m_bkps 1>> $ilog 2>> $elog
rc=$?
if [[ $rc -gt 0 ]]; then
let "ix+=1"
else
let "ix=5"
fi
done
if [[ $rc -gt 0 ]]; then
echo " " >> $elog
echo ">>> Error copying dir: $apps. rc=$rc <<<" >> $elog
exit 1
fi

On my server (ubuntu 8.04) the same script fails. Bash 3.2.39

It complains about "let" and "[[".
I had to change it to this:

date >> $ilog
echo " " >> $ilog
echo "==> Copying $srcdir directory " >> $ilog
ix=0
while [ $ix -lt 3 ]
do
rsync $opt * $trgdir 1>> $ilog 2>> $elog
rc=$?
if [[ $rc -gt 0 ]]; then
ix=$(($ix+1))
else
ix=3
fi
done
if [ $rc -gt 0 ]; then
echo " " >> $elog
echo ">>> copy dir failed: $srcdir. rc=$rc <<<" >>$elog
exit 1
fi

I had to change let to use $(()) and [[ to [

WHY ?
 
Old 10-05-2008, 02:25 PM   #2
lwasserm
Member
 
Registered: Mar 2008
Location: Baltimore Md
Distribution: ubuntu
Posts: 184

Rep: Reputation: 41
I bet your script has "#!/bin/sh" at the top. On the ubuntu system change it to "#!/bin/bash".
Ubuntu 8.04 and some earlier versions link /bin/sh to dash rather than bash, though bash is used for login and interactive shells. The ubuntu developers say that dash executes faster than bash and saves some time at bootup.

I ran into similar problems when I upgraded from ubuntu 6.06, which still used bash for everything, to 8.04, and it had me really confused for a while too.
 
Old 10-06-2008, 05:58 PM   #3
jxrod2000
Member
 
Registered: Apr 2006
Location: MA, USA
Distribution: OpenSuse 11
Posts: 34

Original Poster
Rep: Reputation: 15
That's exactly right. I would have spent hours trying to figure this one out, and end up frustrated.

Thanks for the info and for averting countless hours of frustration.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Routing : Route an ip differently from its ip range bala.linux Linux - Networking 3 05-07-2008 06:58 AM
Seeing hard drive differently pixellany MEPIS 5 10-06-2006 09:49 AM
Mozilla working differently! redhatrosh General 2 05-04-2005 12:29 AM
SuSE works differently from Mandrake? escordeiro Linux - Newbie 1 09-30-2004 08:28 PM
Monitor power off differently with Linux and Xp...!?? yarnar Linux - Software 1 11-16-2003 12:45 AM


All times are GMT -5. The time now is 10:05 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration