Sponsored Content
Full Discussion: checking process existed
Operating Systems HP-UX checking process existed Post 302170677 by jim mcnamara on Tuesday 26th of February 2008 10:18:37 AM
Old 02-26-2008
You can use ftw() or nftw(). Those require you to define a callback function that decides whether or not to continue.

I also don't see why readdir would exit, do you check return codes from opendir() and readdir() when this occurs? If you are using system() to do something, the shell being run in the system call will treat the '#' as a comment, rather than a file name.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

checking for a running process from korn cron

cron starts a job every 10 minutes via a korn shell - I need to determine if the previous process is still running before I allow the new process to start - HELP I've tried ps -ef, etc but I have seen many situation where it says that the is running when it is not - any ideas on how to absolutely... (2 Replies)
Discussion started by: jph
2 Replies

2. Shell Programming and Scripting

Checking the cron process in unix

Hi Experts, Is there any command by which i can chk that the cron process is running fine? Say i have scheduled the cron to run at 10 o clock every monday,Do i need to wait for the time it runs and then chk using ps -ef? Please shed some light. Thanks Ashok. (2 Replies)
Discussion started by: Ashok_oct22
2 Replies

3. Shell Programming and Scripting

Checking for multiple instances of a process

Hi I have a scenario where i need to check multiple instances of a running shell script (abc.sh) . How can I find from inside a running shell script whether any other instance of the same script is running or not? If any other instance of same shell script is running I need to exit from... (4 Replies)
Discussion started by: raghu.amilineni
4 Replies

4. Shell Programming and Scripting

checking file whether existed in another server or not

Hi, i am in 272.22.22.32 server, and i want to check whether a file test.txt file exists in different server like 372.23.23.23 using shell script. can any one help me out. (1 Reply)
Discussion started by: KiranKumarKarre
1 Replies

5. Shell Programming and Scripting

checking file whether existed in another server or not

need a shell script in unix to check whether a file is existed in dir after connecting using ftp (2 Replies)
Discussion started by: KiranKumarKarre
2 Replies

6. Shell Programming and Scripting

Process checking loop

Hi, I want to create a script who will check if the java process is running & if it finds the process is still there it continues to execute & when the process completes it exit from the script. I have written a code to check & notify the process existence but i am not getting how to write... (4 Replies)
Discussion started by: d8011
4 Replies

7. Shell Programming and Scripting

block process checking

How can i check block process in Linux? If found any what action is required? How to check the pid of process? How to kill the block process? How to find out bottleneck process? (3 Replies)
Discussion started by: learnbash
3 Replies

8. Shell Programming and Scripting

My Script For Process Checking is NOT Working

Hello there ULF, Good day! Just want to share my code and as well as my problem on why I'm not getting the output that I want. My original code was: #!/usr/bin/sh echo echo -n "Please input an IP-Pool: " read ip echo echo "Please wait....."... (8 Replies)
Discussion started by: rymnd_12345
8 Replies

9. Shell Programming and Scripting

Problem with a script for checking the state of a process

Hello Everyone, I have a process that should be always running. Unfortunately, this process is getting down almost every 10 minutes. I want to make a script that verify the state of this process: If the process is up, the script shouldn't do nothing and if it's down he should run it. Can... (3 Replies)
Discussion started by: adilyos
3 Replies

10. Shell Programming and Scripting

Checking DataPump Process

Hi All, I am writing script for Env refresh for Oracle DB. I am using Datapump for that. If i start expdp or impdp, how can i know that export or import has completed. I have query for that. How will i integrate with script?. Or any command i can run from Linux side. Please share you... (1 Reply)
Discussion started by: pvmanikandan
1 Replies
FTW(3)							   BSD Library Functions Manual 						    FTW(3)

NAME
ftw, nftw -- traverse (walk) a file tree SYNOPSIS
#include <ftw.h> int ftw(const char *path, int (*fn)(const char *, const struct stat *, int), int maxfds); int nftw(const char *path, int (*fn)(const char *, const struct stat *, int, struct FTW *), int maxfds, int flags); DESCRIPTION
The ftw() and nftw() functions traverse (walk) the directory hierarchy rooted in path. For each object in the hierarchy, these functions call the function pointed to by fn. The ftw() function passes this function a pointer to a NUL-terminated string containing the name of the object, a pointer to a stat structure corresponding to the object, and an integer flag. The nftw() function passes the aforementioned argu- ments plus a pointer to a FTW structure as defined by <ftw.h> (shown below): struct FTW { int base; /* offset of basename into pathname */ int level; /* directory depth relative to starting point */ }; Possible values for the flag passed to fn are: FTW_F A regular file. FTW_D A directory being visited in pre-order. FTW_DNR A directory which cannot be read. The directory will not be descended into. FTW_DP A directory being visited in post-order (nftw() only). FTW_NS A file for which no stat(2) information was available. The contents of the stat structure are undefined. FTW_SL A symbolic link. FTW_SLN A symbolic link with a non-existent target (nftw() only). The ftw() function traverses the tree in pre-order. That is, it processes the directory before the directory's contents. The maxfds argument specifies the maximum number of file descriptors to keep open while traversing the tree. It has no effect in this imple- mentation. The nftw() function has an additional flags argument with the following possible values: FTW_PHYS Physical walk, do not follow symbolic links. FTW_MOUNT The walk will not cross a mount point. FTW_DEPTH Process directories in post-order. Contents of a directory are visited before the directory itself. By default, nftw() traverses the tree in pre-order. FTW_CHDIR Change to a directory before reading it. By default, nftw() will change its starting directory. The current working directory will be restored to its original value before nftw() returns. RETURN VALUES
If the tree was traversed successfully, the ftw() and nftw() functions return 0. If the function pointed to by fn returns a non-zero value, ftw() and nftw() will stop processing the tree and return the value from fn. Both functions return -1 if an error is detected. ERRORS
The ftw() and nftw() functions may fail and set errno for any of the errors specified for the library functions close(2), open(2), stat(2), malloc(3), opendir(3) and readdir(3). If the FTW_CHDIR flag is set, the nftw() function may fail and set errno for any of the errors speci- fied for chdir(2). In addition, either function may fail and set errno as follows: [EINVAL] The maxfds argument is less than 1. SEE ALSO
chdir(2), close(2), open(2), stat(2), fts(3), malloc(3), opendir(3), readdir(3) STANDARDS
The ftw() and nftw() functions conform to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
These functions first appeared in AT&T System V Release 3 UNIX. Their first FreeBSD appearance was in FreeBSD 5.3. BUGS
The maxfds argument is currently ignored. BSD
July 5, 2004 BSD
All times are GMT -4. The time now is 09:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy