I have to have my script wait for another script when it is being executed. I used
to get the PID of the script but when passed the PID to wait command, the command does not accept it as a PID.
Below is the example:
my.script1:
Before I ran the script, I made sure my.script2 is open and being executed
my.script1 does not wait for my.script2 at all. The last echo statement runs immediately after the wait statement.
Also the echo PID statement gives me outputs like below:
I run:
II run:
III run:
From this its clear that the wait command did not see the PIDs from fuser command as PIDs. Is there any way to format the same so that I can make my wait command work?
Also as shown in II run sometimes, I get more than 1 PID from fuser. Let me know how to handle those kind of situations too!
Hi all,
I have the following script:
-------------------------------------------------
#SCRIPT TO CHECK WHO HAS ACCESSED THE LOG/FILE IN PAST 'N' MINUTES, AND MAIL ACCORDINGLY.
MYPATH="/clocal/mqbrkrs/user/mqsiadm/sanjay/"
MAIL_RECIPIENTS="vg517@dcx.com"
Subject="File accessed in last... (6 Replies)
Hi folks,
Please advise which command/command line shall I run;
1) to display the command and its output on console
2) simultaneous to save the command and its output on a file
I tried tee command as follows;
$ ps aux | grep mysql | tee /path/to/output.txt
It displayed the... (7 Replies)
Hi all,
From the below file I need to fetch the data in the below output format.
ToolInstanceID "diw_dm_sales"
Identifier "Sales_source_load"
Promt Default ParamType ParamLength ParamScale
"Database_Name" "ORCL" "0" "0" "0"
Identifier "retail_source_load"
Promt Default... (4 Replies)
Hi
i have a file which have a pattern like this
Nov 10 session closed
Nov 10 Nov 9 08:14:27 EST5EDT 2010 on tty .
Nov 10 Oct 19 02:14:21 EST5EDT 2010 on pts/tk .
Nov 10 afrtetryytr
Nov 10 session closed
Nov 10 Nov 10 03:21:04 EST5EDT 2010
Dec 8 Nov 10 05:03:02 EST5EDT 2010
... (13 Replies)
Hi,
Can anyone explain me the difference between fsuer and lsof commands. As per my knowledge both the commands are used to find the processes used by the current file system or user. Apart from that what is the major difference between these commands (3 Replies)
Hi,
Not sure whether there is a fuser alternative or any better way to check for file in use or not.
I am wanting to check whether files are in use or not before removing them. Using fuser, the awk seems to be giving me 'weird' output not to mention that it is giving me 2 lines instead of... (0 Replies)
I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place.
What I need
The following command is placed at the prompt:
TICLI... (4 Replies)
Hi there,
What is the equivalent of fetch command in Ubuntu/Cygwin. My purpose is to modify the code in such a way that I can use fetch.
#!/bin/sh
#============================================================================
# $Id: ios-http-auth.sh,v 1.1 2001/06/29 00:59:44 root Exp root... (1 Reply)
Discussion started by: alvinoo
1 Replies
LEARN ABOUT OSF1
fuser
fuser(2) System Calls Manual fuser(2)NAME
fuser - Reports PIDs and UIDs for files, file systems and/or the devices attached to them.
SYNOPSIS
#include <sys/fuser.h>
int fuser(
char *file,
long flag,
struct f_user fuser_array[],
long sizeof_fuser_array );
PARAMETERS
Specifies the file name. Specifies one of the following values. If none of the following are values are specified, the default is to
match open files. Matches only file ids. Provides mount point matching. Matches deleted files on the mount point specified by file.
Specifies the array. Specifies the number of elements in the fuser array.
DESCRIPTION
The fuser function reports a list of PIDs and UIDs that are associated with a specified file, file system, and/or the devices that are
attached to them.
The fuser function can report back additional information about "matches" by ORing one of the following constants that can be passed back
in the member fu_flags: Current directory Current directory Parent of the current directory At least one file open, but the number open is
not known. Executable image. Controlling terminal Trace At least one file is mmapped
RETURN VALUES
On success, the fuser function returns the number of fuser_array elements that were found. The contents of the structure are as follows:
typedef struct f_user {
pid_t fu_pid;
int fu_flags;
uid_t fu_uid; } f_user_t;
If an error has occurred, the fuser function returns -1 and sets errno to indicate the error.
ERRORS
If the fuser function fails, errno may be set to one of the following values: The array is not large enough to hold the number of array
elements returned or the array structure cannot be filled The file parameter specified does not exist
EXAMPLES
Open regular files and special files are matched using the flag parameter set at 0L. Thus, if process 127 and 3220 open the /home/try file
simultaneously and the fuser function is active, the PIDs and UIDs associated with the home/try file are reported as in the following exam-
ple:
fuser("/home/try", 0L, fuser_array,
(long) (sizeof (fuser_array)/sizeof(fuser_array[0])); Similarly, if the special device file /dev/ttyp2 is open by process 32,
then that PID and its associated UID are reported as in the following example:
fuser("/dev/ttyp2", 0L, fuser_array,
(long) (sizeof (fuser_array)/sizeof(fuser_array[0]));
fuser(2)