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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-21-2003, 03:29 PM
|
#1
|
|
LQ Newbie
Registered: May 2003
Posts: 9
Rep:
|
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
|
|
|
|
10-21-2003, 03:42 PM
|
#2
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
I think you'll need to use:
Code:
#!/bin/ksh
if [ -f 123 ] && [ -f 456 ]; then
echo "yes"
else
echo "no"
fi
|
|
|
|
10-22-2003, 08:42 AM
|
#3
|
|
LQ Newbie
Registered: May 2003
Posts: 9
Original Poster
Rep:
|
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
|
|
|
|
10-24-2003, 02:14 PM
|
#4
|
|
LQ Newbie
Registered: May 2003
Posts: 9
Original Poster
Rep:
|
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
|
|
|
|
10-24-2003, 03:32 PM
|
#5
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
What else is in that folder? Are the other items consitant?
|
|
|
|
10-24-2003, 07:52 PM
|
#6
|
|
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:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:24 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|