LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-14-2009, 10:54 AM   #1
LQ Newbie
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
How to find out what is causing command not found in script

I have a very small script which queries a mySQL table and puts the result into a variable. Actually that is what I want to do.

When I just run the mysql command on the command line it works fine.
Put into the script and run the script the script returns the result plus has at the end the command not found as well.
see below... 23 is the actual result from the query but what is causing the command not found at the end?

./ line 4: 23: command not found

How can I figure out what is causing that.

Below my code

sqlcount= `mysql --host=host --user=user --password=apassword --silent --skip_column_names -e"SELECT count(*) as Users_Logged_On FROM user_logon u WHERE logon_state='Logged On' and LOGON_DT >= curdate();" aDatabase`

echo $sqlcount
Old 03-14-2009, 10:56 AM   #2
Senior Member
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Assigning a value to a variable is as follows:
Remove the space between the = and your backticked command:

sqlcount=`mysql --host=host --user=user --password=apassword --silent --skip_column_names -e"SELECT count(*) as Users_Logged_On FROM user_logon u WHERE logon_state='Logged On' and LOGON_DT >= curdate();" aDatabase`

echo $sqlcount
Your error was that the output of your mysql command was 23, which sh was trying to execute as a command, which it couldn't.

Last edited by pwc101; 03-14-2009 at 10:58 AM.


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
BASH Script - command not found!! JavaNinja Linux - Newbie 12 12-01-2008 12:45 PM
egrep to find a command not found string romainp Linux - General 1 09-07-2007 04:30 PM
Bash script says command not found - why? RavenLX Ubuntu 3 08-03-2007 03:19 PM
Bash Script; command not found twintornado Programming 2 06-01-2005 10:59 AM
command not found (My shell script) Swift&Smart Linux - Software 3 05-16-2004 12:14 AM

All times are GMT -5. The time now is 04:57 PM.

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