English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have a MySQL database with clients info in it: name, ipaddres, mac address, status

I want to do a bash script witch takes these and output in a file in this format:
surname1_name1,ipaddress1,macaddress1,status1
surname2_name2,ipaddress2,macaddress2,status2
etc...

So I can use my firewall script to get the ip's from the file and see if their status is 1 or 0 and use this information for the rules.

2006-09-01 09:51:08 · 1 answers · asked by Marton G 1 in Computers & Internet Programming & Design

1 answers

you would probably be better of using a Perl or PHP script called from a bash script to do this.

You can call run a MySQL query through bash by using:
mysql -h hostname -u username -p -D databaseName -e "SELECT * FROM table";

But this will output it with all the headers, etc. There may be options to remove this, but you would be better off using something designed to parse this than writing a bash script.

2006-09-01 10:10:19 · answer #1 · answered by John J 6 · 0 0

fedest.com, questions and answers