01-14-2009
shell scripting on unix/mysql problems
Hi,
I have written a shell script for oracle on unix that does a df for specific files, and then will display the size, Avail, % used and the difference from yesterday to today.
I have been asked to place it on some MySql databases that run onn unix and linux also, but when I try to run them I am getting some bizar errors. Not knowing anything about MySql, I am in need of some help.
Here is a portion of the script and the errors I get just for those lines. Help please, or even if you can recommend a book that deals with shell scripting on mysql?
set F_SYSTEMS= ( /mysql )
set OUTFILE=${WORK_DIR}/files.out
set TMPFILE=${WORK_DIR}/temp
set WRKFILE=${WORK_DIR}/files.txt
set ARCHFILE=${WORK_DIR}/fs_yesterday.out
#*********************************************************************
#* Loop through the list of partitions
#*********************************************************************
printf '%12s %79s\n' "(KB)" "DAY TO DAY">> ${OUTFILE}
printf '%12s %11s %11s %6s %-34s %10s\n' "SIZE" "USED" "AVAIL" "%USED" "MOUNTED" "DELTA">> ${OUTFILE}
foreach PARTITION (${F_SYSTEMS})
df -k ${PARTITION} > ${WRKFILE}
grep -v Filesystem ${WRKFILE} | grep % | tr -s "" " " | sed -e 's/^ //g' | sed -e 's/^ //g' > ${TMPFILE}
if (`cut -c1 ${TMPFILE}` == '/') then
set SIZ=`cut -d" " -f2 ${TMPFILE}`
set USD=`cut -d" " -f3 ${TMPFILE}`
set AVAIL=`cut -d" " -f4 ${TMPFILE}`
set PCT=`cut -d" " -f5 ${TMPFILE} | sed -e 's/%//'`
set MNTD=`cut -d" " -f6 ${TMPFILE}`
else
: ./my.csh
./my.csh: line 21: syntax error near unexpected token `('
./my.csh: line 21: `set F_SYSTEMS=( /mysql )'
./my.csh: line 32: $OUTFILE: ambiguous redirect
./my.csh: line 33: ${OUTFILE}: ambiguous redirect
./my.csh: line 35: syntax error near unexpected token `('
./my.csh: line 35: `foreach PARTITION (${F_SYSTEMS})'
./my.csh: line 35: foreach: command not found
Does anyone have a clue what these errors are wanting?
I have tried going through and changing, for example, set F_SYSTEMS=( /mysql ) to F_SYSTEMS= /mysql
and $(OUTFILE) to OUTFILE
but when it tells me that 'foreach: command not found' I am stymied as to what to do nex.
Any help will be greatly appreciated,
thanks,
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies
2. Shell Programming and Scripting
Hello all-
I have done a lot of searching tonight, but all leads seem to be dead ends. Forgive me if this has been covered, but I've searched the forum and the internet. I am having trouble building a shell script which uses SSH to login to our schools 1024 cluster grid. The issue that I am... (1 Reply)
Discussion started by: Sagan
1 Replies
3. Programming
Hi,
i have been developing a shell script to transfer a set of files from one ubuntu system to another.
Task: while executing the script the files ( ls, dir, cat) in the source machine should transfer to destination machine(at /home/mac/mac/bin)
While the script is executed once again, It... (0 Replies)
Discussion started by: srijith
0 Replies
4. Shell Programming and Scripting
Hi to all guyz ,
As i'm new to Shell scripting i was been working out to write a shell script for mysql Replication for multiple slave master architecture.i have done the process up with a script of 200 lines but still there are some things which can make my script more effective so i want your... (5 Replies)
Discussion started by: kgrvamsi
5 Replies
5. Shell Programming and Scripting
Hi,
In my unix server, i received a file in /usr/data/xmit location. i want to write a unix script after file reached.
So how can i write a one line code which chceks the presence of the file? and second line line should take the status of the prevous line. like below.
Line 1: checks for the... (16 Replies)
Discussion started by: JSKOBS
16 Replies
6. UNIX for Dummies Questions & Answers
Hi Friends,
I Want to comment one line of code from below code.
DBA_ORACLE_USER=`DB.sh -u -a User`
DBA_ORACLE_PWORD=`DB.sh -p -a User`
sqlplus /nolog <<-END > ${logfile} 2>&1
WHENEVER OSERROR EXIT 9
WHENEVER SQLERROR EXIT SQL.SQLCODE
connect... (3 Replies)
Discussion started by: as234301
3 Replies
7. Shell Programming and Scripting
Hi All,
Please see the below script for mysql 3 commands. Its giving me the right output for all three commands but showing some errors in first two commands , i guess there might be an issue with date.
Can anyone help me .
#! /bin/bash
TABLE_NAME=testingddatabase
USER_NAME=root... (3 Replies)
Discussion started by: aish11
3 Replies
8. UNIX for Dummies Questions & Answers
Hello Experts,
I have the following questions to be discussed here at this esteemed discussion forum.
I have two Excel sheets which contain Unix Commands llike creating directory the structure/ftp/Copy/Zip etc to basically create an environment. I need help in understanding some of... (1 Reply)
Discussion started by: faizsaadq
1 Replies
9. Shell Programming and Scripting
Hi all,
I'm just learning to write shell scripts (new to the whole UNIX thing) and I'm wondering if anyone would like to help me create a resource to help me, and others like me, learn scripting. It would be something like "100 interesting shell scripting problems".
All I need are... (7 Replies)
Discussion started by: nickednamed
7 Replies
10. Programming
Hi All,
need help to complete the automation but stuck at a perticular situation
below is the code
<code>
fixed_function_name
{
code....
code....
variable_map=
{
a="/a"
b="/b"
c="/c"
so on...
} (7 Replies)
Discussion started by: yadavricky
7 Replies
UUX(1C) UUX(1C)
NAME
uux - unix to unix command execution
SYNOPSIS
uux [ - ] command-string
DESCRIPTION
Uux will gather 0 or more files from various systems, execute a command on a specified system and send standard output to a file on a spec-
ified system.
The command-string is made up of one or more arguments that look like a shell command line, except that the command and file names may be
prefixed by system-name!. A null system-name is interpreted as the local system.
File names may be one of(1) a full pathname;
(2) a pathname preceded by ~xxx; where xxx is a userid on the specified system and is replaced by that user's login directory;
(3) anything else is prefixed by the current directory.
The `-' option will cause the standard input to the uux command to be the standard input to the command-string.
For example, the command
uux "!diff usg!/usr/dan/f1 pwba!/a4/dan/f1 > !fi.diff"
will get the f1 files from the usg and pwba machines, execute a diff command and put the results in f1.diff in the local directory.
Any special shell characters such as <>;| should be quoted either by quoting the entire command-string, or quoting the special characters
as individual arguments.
FILES
/usr/uucp/spool - spool directory
/usr/uucp/* - other data and programs
SEE ALSO
uucp(1)
D. A. Nowitz, Uucp implementation description
WARNING
An installation may, and for security reasons generally will, limit the list of commands executable on behalf of an incoming request from
uux. Typically, a restricted site will permit little other than the receipt of mail via uux.
BUGS
Only the first command of a shell pipeline may have a system-name!. All other commands are executed on the system of the first command.
The use of the shell metacharacter * will probably not do what you want it to do.
The shell tokens << and >> are not implemented.
There is no notification of denial of execution on the remote machine.
UUX(1C)