![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| exec to call specific function in C prog | vpraveen84 | UNIX for Advanced & Expert Users | 2 | 06-03-2008 03:55 PM |
| alternatives of exec() system function | Raj Kumar Arora | High Level Programming | 3 | 01-03-2008 02:27 AM |
| How to periodically execute a function in C ?? | RipClaw | High Level Programming | 24 | 12-27-2007 12:19 AM |
| query about find and -exec | shriashishpatil | UNIX for Advanced & Expert Users | 2 | 04-12-2007 02:16 AM |
| find and exec | big123456 | UNIX for Advanced & Expert Users | 2 | 01-02-2006 12:10 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How can I execute own ksh function in find -exec
Hi,
I wrote a smiple ksh function send_notification() { ... } and want to execute it on each file, matched by the find command. I tried: find / -name "*.err" -mtime -8 -exec send_notification {} \; but it doesn't work. What should I do? I work in ksh on Hp-Ux. Regards, Pit |
|
||||
|
I think its not possible to execute function.Instead make a shell script send_not.sh and call that script in find command Code:
send_not.sh
############
send_notification() {
...
}
send_notification $1
############
Code:
find / -name "*.err" -mtime -8 -exec /dir1/dir2/send_not.sh {} \;
|
|
||||
|
Thank you for reply.
I know that I can place that function in a separate file. On that way it has been working for a long time but I was asked to place everything in one shell script. Pit Last edited by piooooter; 04-02-2007 at 02:03 PM.. |
|
||||
|
Thank you again for reply.
The last solution seems to be almost ok, but there is another problem. It executes the command find / -name "*.err" -mtime -8 -print and when finishes it goes inside for loop. Because the find command searches through very large storage system it is required that the send_notification function is executed for each found item at the time it's found. |
![]() |
| Bookmarks |
| Tags |
| mtime |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|