Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-18-2004, 10:06 AM   #1
Registered: Jan 2003
Distribution: many win/nix/mac
Posts: 259

Rep: Reputation: 31
Bash script and mysql

I'm trying to use a bash script to query mysql and extract a number from a table then do something with the number.

This gives me a nice clean output without the little mysql box or column name:

mysql --skip-column-names -B -s -e "use proftpd; select max(uid) from users;" --password=$MYSQLPASSWORD

The idea is to create users in a mysql authentication backend for proftp--the script above gives the highest user id --- what I would like the bash script to do is assign the next available number -- so the above script + 1

I cant get bash to accept the output of the above as a variable

If someone can help I would sure appreciate it



Last edited by flashingcurser; 07-18-2004 at 01:58 PM.
Old 07-19-2004, 03:35 AM   #2
Registered: Jul 2004
Location: Rio de Janeiro - Brazil
Distribution: Conectiva 10 - Conectiva 8 - Slackware 9 - starting with LFS
Posts: 519

Rep: Reputation: 34
bash_var=`mysql --skip-column-names -B -s -e "use proftpd; select max(uid) from users;" --password=$MYSQLPASSWORD`
bash_var=`expr $bash_var + 1`
Remember, the commands are surrounded by grave accent.


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 + Mysql Help xianzai Programming 4 10-28-2004 08:15 AM
Mysql in bash script acrors Red Hat 2 08-18-2004 09:11 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:46 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