LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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-16-2003, 11:09 AM   #1
wedgeworth
Member
 
Registered: Aug 2003
Posts: 234

Rep: Reputation: 30
script is capturing output....


why isn't this script working. i get e-mailed and when i run the script from the command line i get the correct output to the screen from the "myisamchk" command, however all that makes it to the e-mail is the line "Output for mysql table check ". can anyone tell me why the output from the "myisamchk " isn't getting sent in the body to my e-mail?

script:



#!/bin/sh

DATE=`date +%m-%d-%y`

echo "Output for mysql table check "`date` > /tmp/tbl_check.log

IFS="
"
for file in `myisamchk -esw /usr/var/mysql/*/*.MYI`; do
echo $file
echo $file >> /tmp/tbl_check.log
rm -f $file
done

cat /tmp/tbl_check.log | mail me@yahoo.com -s "mysql tbl_check mercury $DATE"
rm -f /tmp/tbl_check.log

Last edited by wedgeworth; 10-16-2003 at 11:12 AM.
 
Old 10-16-2003, 12:23 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,792

Rep: Reputation: 292Reputation: 292Reputation: 292
I do not think that you are initializing the file variable. $file is always null.


___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 10-16-2003, 12:28 PM   #3
wedgeworth
Member
 
Registered: Aug 2003
Posts: 234

Original Poster
Rep: Reputation: 30
i've never had to before. example below scritp WORKS FINE:

#!/bin/bash

DATE=`date +%m-%d-%y`

echo "Starting new cleanup "`date` > /tmp/cleanup.log

IFS="
"
for file in `find /usr/var/backups/ -ctime +10 -type f`; do
echo $file
echo $file >> /tmp/cleanup.log
rm -f $file
done

cat /tmp/cleanup.log | mail me@yahoo.com -s "Cleanup log $DATE"
rm -f /tmp/cleanup.log



i'm wondering if it has something to do with the "myisamchk " command because the above script worked fine in getting output from find. i dont' understand why it isn't getting it from "myisamchk"
 
Old 10-17-2003, 10:25 AM   #4
wedgeworth
Member
 
Registered: Aug 2003
Posts: 234

Original Poster
Rep: Reputation: 30
is there any reason why the find command (works in script) and the myisamchk command (does not work in script) would be treated differently or act differently so that the script would not cature the output correctly?

Last edited by wedgeworth; 10-17-2003 at 10:26 AM.
 
Old 10-17-2003, 11:14 AM   #5
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,792

Rep: Reputation: 292Reputation: 292Reputation: 292
"why isn't this script working."


The command:
for file in `myisamchk -esw /usr/var/mysql/*/*.MYI`; do
runs the command `myisamchk -esw /usr/var/mysql/*/*.MYI`;

Then the command is composed into:
for file do
If the value of file is 0 or null then the do loop is not run.
If the value of file is non 0 then the do loop is run.
So, for whatever reason `myisamchk -esw /usr/var/mysql/*/*.MYI`;
is setting a return value of 0 for file and the do loop never executes.

In the case of:
for file in `find /usr/var/backups/ -ctime +10 -type f`; do
find returns file names if it finds files that meet the criteria or 0 if it does not.
Therefore:
for file in `find /usr/var/backups/ -ctime +10 -type f`; do
will execute the doo loop whenever a file meets the find criteria and not execute the do loop whenever find returns a 0 for no file found.

The bug is in the myisamchk command. It is only returning a 0 return code. The file variable is never set to anything other than 0 so the do loop never executes.



___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 10-17-2003, 01:38 PM   #6
wedgeworth
Member
 
Registered: Aug 2003
Posts: 234

Original Poster
Rep: Reputation: 30
ok, so does anyone know of a better script on how to capture the output from the myisamchk command?
 
Old 10-20-2003, 11:41 AM   #7
wedgeworth
Member
 
Registered: Aug 2003
Posts: 234

Original Poster
Rep: Reputation: 30
is there some better way of redirecting the output to some log file that will actually work? could i actually just take the command out of the loop and just redirect find myisamchk to a log file? (sorry i can't test this out at the moment before posting.... i'm "locked" out of my mysql files)

Last edited by wedgeworth; 10-20-2003 at 11:44 AM.
 
Old 10-20-2003, 06:11 PM   #8
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,792

Rep: Reputation: 292Reputation: 292Reputation: 292
myisamchk

I found a myisamchk manual at:
http://www.mysql.com/doc/en/Table_maintenance.html

In this manual it describes how to create a log file using the --debug option:
http://www.mysql.com/doc/en/myisamch...l_options.html

You might play around with --debug and see what you can do. In any case I did not find out anything about myisamchk return codes in my quick scan of the manual.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
  


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
capturing output of 'faad -i'.... bulliver Programming 3 09-18-2005 07:51 PM
Capturing video with Cinelerra works, capturing video with Xawtv doesn't! seaelf Slackware 0 06-27-2004 06:18 PM
capturing output from "find" wedgeworth Linux - Software 3 10-10-2003 03:38 PM
Capturing from TV card with mplayer, output is at half speed Electrode Linux - Software 2 09-28-2003 01:06 AM
Capturing standard output from external program brianvdc Linux - Software 1 02-12-2003 04:20 AM


All times are GMT -5. The time now is 06:08 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration