- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell Scripts help..........
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 06:10 PM
11-08-2001 06:10 PM
I need a help to develop a shell script as per the Document Attached..
Thanks for the Advance in Help..
Regards
Raj..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 08:55 PM
11-08-2001 08:55 PM
Re: Shell Scripts help..........
Any SysAdmins, please respond
Thanks
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 03:59 AM
11-09-2001 03:59 AM
Re: Shell Scripts help..........
How about:
=====================================
#!/bin/ksh
FILE1=/home/test/bacuss/bac1.log
FILE2=/home/test/bacuss/deletion.props
grep FILE_NAME $FILE2 | cut -d= -f2 | read FN
grep RETAIN_PEND $FILE2 | cut -d= -f2 | read RP
grep BACK_FILE_EXT $FILE2 | cut -d= -f2 | read BFE
grep RETAIN_SEND $FILE2 | cut -d= -f2 | read RS
cat $FILE1 | while read DIR ; do
find $DIR -name "*$FN" -mtime +$RP | xargs rm
find $DIR -name "*$BFE" -mtime +$RS | xargs rm
done
======================================
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2001 08:01 PM
11-11-2001 08:01 PM
Re: Shell Scripts help..........
When i run the script which you have given to me ........ITS HANGING.....What could be the reason???
Thanks & Regards
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2001 08:15 PM
11-11-2001 08:15 PM
Re: Shell Scripts help..........
Its working now...
Is it possible to write the status to "SYSLOG" file using logger command??? I mean whether it is success or unsuccessfulll ???
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2001 11:26 PM
11-11-2001 11:26 PM
Re: Shell Scripts help..........
And then call this exe from your script, passing to it the message to be logged.
HTH

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 12:58 AM
11-12-2001 12:58 AM
Re: Shell Scripts help..........
One more clarification reagarding script....
While executing the below script it has to delete only "DAT" files only.
It is deleting the "DAT" as well as "X_" files..Is is possible to read only specific whose files starting with "X_" ?????
==============================
#!/bin/ksh
FILE1=/home/test/bacuss/bac1.log
FILE2=/home/test/bacuss/deletion.props
grep FILE_NAME $FILE2 | cut -d= -f2 | read FN
grep RETAIN_PEND $FILE2 | cut -d= -f2 | read RP
cat $FILE1 | while read DIR ; do
find $DIR -name "*$FN" -mtime +$RP | xargs rm
done
==============================
Waiting for your reply..
R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 01:09 AM
11-12-2001 01:09 AM
Re: Shell Scripts help..........
If you change:
find $DIR -name "*$FN" -mtime +$RP | xargs rm
to
find $DIR -name "X_*$FN" -mtime +$RP | xargs rm
is that what you're after?
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 01:33 AM
11-12-2001 01:33 AM
Re: Shell Scripts help..........
I mean if i execute the above script it has to delete only "DAT" files but it is deleting "X_" files also...I dont want to delete the files starting with prefix "X_"
My requirement according to above script is I want to delete the files having the extention "DAT" only...
These are the files which i am having.....
Nov 6 09:06 X_file06.DAT
Nov 6 09:06 X_file06.DAT
Nov 7 09:05 X_file07.DAT
Nov 7 09:05 X_file07.DAT
Nov 8 09:04 X_file08.DAT
Nov 8 09:04 X_file08.DAT
Nov 9 09:03 X_file09.DAT
Nov 9 09:03 X_file09.DAT
Nov 10 09:02 X_file10.DAT
Nov 10 09:02 X_file10.DAT
Nov 11 09:01 X_file11.DAT
Nov 11 09:01 X_file11.DAT
Nov 6 09:00 file06.DAT
Nov 7 09:00 file07.DAT
Nov 8 09:00 file08.DAT
Nov 9 09:00 file09.DAT
Nov 10 09:00 file10.DAT
I mean the script has to ignore the files starting with "X_" and has to delete only extention "DAT" files..
Please help me...
Ra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 01:47 AM
11-12-2001 01:47 AM
Re: Shell Scripts help..........
Once again
While deleting the files having the extension "DAT" it has to ignore the files starting with "X_"
In the script There must be some condition to eliminate the prefix "X_" files while deleting the files extension "DAT"
And "X_" & "DAT" should be read only from the parameter file "deletion.props".It should not be hardcoded in the script.....
Please kindly cooperate to solve the problem...
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 01:53 AM
11-12-2001 01:53 AM
Re: Shell Scripts help..........
A couple of ways:
find $DIR -name "*$FN" -mtime +$RP | grep -v X_ | xargs rm
or
find $DIR \( -name "*$FN" -a ! -name "X_*" \) -mtime +$RP | xargs rm
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 02:04 AM
11-12-2001 02:04 AM
Re: Shell Scripts help..........
I used what ever you have given ,still its showing all the "DAT" files along with "X_" files..
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 02:12 AM
11-12-2001 02:12 AM
Re: Shell Scripts help..........
You may need to put "-print" at the end of the find command.
Can you post the latest version of all your files please?
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 02:26 AM
11-12-2001 02:26 AM
Re: Shell Scripts help..........
I have attached all the script s..Please review...
Thanking you..
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 02:46 AM
11-12-2001 02:46 AM
Re: Shell Scripts help..........
I'd remove the "#!/bin/sh" from the top of bac1.log. This is causing the find to "fail" and the xargs to list all the files in the current directory (is this what you're seeing?).
Apart from that, I can see no problems.
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 03:25 AM
11-12-2001 03:25 AM
Re: Shell Scripts help..........
Fanastic,,Its working fine..
I have attached the scipts which i have executed independently..
Waiting for your responce..
Regards
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 03:41 AM
11-12-2001 03:41 AM
SolutionTry this:
FILE1=/home/rajkumar/in_dir/bac1.log
FILE2=/home/rajkumar/in_dir/deletion.props
grep FILE_NAME $FILE2 | cut -d= -f2 | read FN
grep RETAIN_PEND $FILE2 | cut -d= -f2 | read RP
grep BACK_FILE_EXT $FILE2 | cut -d= -f2 | read BFE
grep RETAIN_SEND $FILE2 | cut -d= -f2 | read RS
COUNT=0
cat $FILE1 | while read DIR ; do
if [ ! -d "$DIR" ] ; then
logger "$0 : $DIR not found"
continue
fi
find $DIR -name "*$FN" -mtime +$RP | grep -v $BFE | while read FILE ; do
rm $FILE && logger "$0 : for directory $DIR, $FILE deleted"
COUNT=$(expr $COUNT + 1)
done
find $DIR -name "$BFE*" -mtime +$RS | while read FILE ;do
rm $FILE && logger "$0 : for directory $DIR, $FILE deleted"
COUNT=$(expr $COUNT + 1)
done
if [ "$COUNT" -gt 0 ] ; then
logger "$0 : for directory $DIR, $COUNT files removed"
else
logger "$0 : for directory $DIR, no matching files found"
fi
done
exit 0
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 04:17 AM
11-12-2001 04:17 AM
Re: Shell Scripts help..........
The message status of the deletion files only i am able to see..If there are no files there is no message status in the SYSLOG...
i mean files not found like that....
Can you please review???
Thanks
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 04:23 AM
11-12-2001 04:23 AM
Re: Shell Scripts help..........
I have attached the STATUS3.log file ..
Thanks
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 04:39 AM
11-12-2001 04:39 AM
Re: Shell Scripts help..........
I'm not sure I know what you mean - the find command will only find files that exist, so you shouldn't see "file not found".
You may want to move "COUNT=0" to after the first "while ...", so that it gets reset for each directory.
Please explain further if this is not correct.
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 05:00 AM
11-12-2001 05:00 AM
Re: Shell Scripts help..........
Exactly,You are correct...
Thank you for your support...
If any problem occurs i will post it in this FAQ only..
Regards
Rajkumar