LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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-21-2003, 03:29 PM   #1
jdara1
LQ Newbie
 
Registered: May 2003
Posts: 9

Rep: Reputation: 0
help requd to fix this script problem


We have got lot of aix and linux boxes. We have one script in AIX, on AIX the script works fine, now I want to implement in Linux, it breaks at one logic, I have written small script to show you wherever it is breaking for your info. Any help in fixing will be highly appreciated.

The small script whatever I have written is this

[u01pms20@u060ms20 scripts]$ cat t.ss
#!/bin/ksh

if [ -f 12345.000 23456.000 c123.000 ]; then
echo "yes"
else
echo "no"
fi

Here please note one point, I can have multiple flat files like
above in the file check condition, means not always 3 , some times it can be 1 or even 3 or even 10 there is no limit.

Some process creates files like that, this script should goes and checks if there are files it email me. But when I ran the sample script it is complaining about unexpected operator etc., which you can see. I would like to stick with ksh only not bash.

When I run this

[u01pms20@u060ms20 scripts]$ ./t.ss
./t.ss[7]: [: 23456.000: unexpected operator/operand
no

Little more[u01pms20@u060ms20 scripts]$ uname -a
Linux u060ms20 2.4.18-18.7.xsmp #1 SMP Wed Nov 13 19:01:42 EST 2002 i686 unknown info what I am using

This is Red hat linux version 7

Thanks
Jagadish
 
Old 10-21-2003, 03:42 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
I think you'll need to use:
Code:
#!/bin/ksh

if [ -f 123 ] && [ -f 456 ]; then
echo "yes"
else
echo "no"
fi
 
Old 10-22-2003, 08:42 AM   #3
jdara1
LQ Newbie
 
Registered: May 2003
Posts: 9

Original Poster
Rep: Reputation: 0
The real script looks like this which was running fine in AIX. I mean
the if condition.

if [ -f [cdtl0-9][0-9][0-9][0-9]*([0-9]).[0-9][0-9][0-9] ]; then

If you notice the logic the number of files it is checking is unlimited

I cannot implement your logic here,
some time thes script checks for existence of 1 file or n files.

Thanks
Jagadish
 
Old 10-24-2003, 02:14 PM   #4
jdara1
LQ Newbie
 
Registered: May 2003
Posts: 9

Original Poster
Rep: Reputation: 0
This is my actual requirement.

We have db2 udb running 30 linux boxes. Some times db2udb generates files like this
23492.000 or t12345.000 or c12345.000 or l12345.000

We do have db2 udb running 10 AIX boxes, we have got a script which was written in korn shell , the script is in cron, it will check every day and email to our group of DBA's if it finds any one of those files in one particualr directory.
/home/db2inst1/sqllib/db2dump.

The same script when I brought from AIX to linux it is not working. When I posted initially I didnot get any solution, later I pasted very small script providing only the logic where in linux it is failing.
I think now it may be clear to you.

In linux I am looking this, the script should check for any
similar files are present it should do some action, in our case it sends emails.

Files of this format
23492.000 or t12345.000 or c12345.000 or l12345.000
Here please note one thing - The number of files it puts is unlimited, those numbers are the process id numbers means they are not constant.( When I say process id numbers, I mean 12345 or 23492 etc.,)
Even though I posted at 3 places, I did not get a good answer till now, looks like my requirement is not clear to linux guru's.
If anybody needs more details on the requirement, I will be happy to answer.

The logic which works in AIX is this
if [ -f [cdtl0-9][0-9][0-9][0-9]*([0-9]).[0-9][0-9][0-9] ]; then
echo "file is present"
fi

Thanks
Jagadish
 
Old 10-24-2003, 03:32 PM   #5
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
What else is in that folder? Are the other items consitant?
 
Old 10-24-2003, 07:52 PM   #6
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
How about using find and grep? I think grep would correctly use your regexp:

if [ -z `find /path/to/searched/dir -type f | grep -E "PutYourRegexpHere"` ] ; then
echo "no files"
else
echo "there are files"
fi
 
  


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
all attempts to fix the problem failed... can someone help me fix partition space? foreverdita Linux - Enterprise 2 05-11-2005 09:02 AM
where do I start to fix the problem? mandrakemikael Linux - General 1 12-26-2004 02:31 PM
Sound problem fix nextekcarl Linux - General 1 10-04-2004 08:33 AM
how to fix this script jdara1 Linux - Software 1 10-23-2003 12:14 PM
Fix a path problem spooodini Linux - General 1 10-22-2003 11:38 PM


All times are GMT -5. The time now is 09:05 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration