LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 09-20-2018, 12:36 PM   #1
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Rep: Reputation: Disabled
Bash Install Errors


All,

Due to all the issues I've encountered with MySQL at:

https://www.linuxquestions.org/quest...ms-4175637410/

I've downloaded all the tar and deb files from 5.5 to 8.0, so have been writing a BASH script to install each version to find where it actually breaks.

Problem is I'm getting errors from my script at this section:
Code:
ver=$1;
echo "Ver=> $ver";
if [ $ver >= "5.5" ] && [ $ver < "6" ]; then 
	src_dir='/home/path/MySQL/5.5+/';
elif [[ $ver >= "6" ] && [ $ver < "7" ]]; then 
	src_dir='/home/path/MySQL/6.0/';
elif [[ $ver -ge "7" && $ver -lt "8" ]]; then 
	src_dir='/home/path/MySQL/7.0/';
elif [ $ver -ge "8" ]; then 
	src_dir='/home/path/MySQL/8.0/';
else
	echo "No correct version entered!";
	exit;
fi
You can see I've tried double brackets and the "-ge", "-lt" vs ">=", "<" the other and always get errors, so need some help on the syntax here, cause not figuring it out.

Output & Errors are:
Quote:
bash /Scripts/MySQL/mysql_ins.sh 5.5
Ver=> 5.5
/Scripts/MySQL/mysql_ins.sh: line 8: [: 5.5: unary operator expected
/Scripts/MySQL/mysql_ins.sh: line 10: [: missing `]'
/Scripts/MySQL/mysql_ins.sh: line 12: [: missing `]'
/Scripts/MySQL/mysql_ins.sh: line 14: [: 5.5: integer expression expected
No correct version entered!
Cheers!
TBNK
 
Old 09-20-2018, 01:10 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,750

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
According to the results of a web search for "unary operator expected", the variable should be quoted in line 8 (guessing at line numbers here)...and probably always.

Can you not see the missing ]'s in lines 10 and 12? We can.

You can't compare a non-integer value to an integer on line 14

Try using a case instead of attempting ranges of numbers, given that there are only four correct input values.

and add set -x to the beginning of your script to see what bash sees.
 
Old 09-20-2018, 01:28 PM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
yes, your if statements are not even constant. use [[ ]] or [ ] and if spliting them between and && they stay constant
Code:
if [[ $var1 -eq '4' ]] && [[ $var2 == 'yo' ]] ; then ...
for binary, string comparisons, and single and double brackets
http://tldp.org/LDP/abs/html/comparison-ops.html

Last edited by BW-userx; 09-20-2018 at 01:31 PM.
 
Old 04-03-2020, 03:10 PM   #4
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
Thanks all marking solved
 
  


Reply



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
SCP bash errors jscottcc Programming 5 07-18-2013 02:46 AM
[SOLVED] Bash scripting errors theonislair Programming 4 08-02-2012 04:23 AM
Command errors vs. bash errors a_d1234 Linux - Newbie 2 11-21-2011 03:53 PM
Bash script has errors smeezekitty Programming 30 11-19-2009 03:34 PM
bash errors after update JonathonReinhart Linux - Software 13 01-21-2006 12:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration