Sponsored Content
Top Forums Shell Programming and Scripting problem redirecting output of command to variable Post 302223093 by drl on Friday 8th of August 2008 10:15:45 AM
Old 08-08-2008
Hi.

I have not used fuser, but I notice something that might point you in the right direction:
Quote:
The process IDs are printed as a single line on the standard
output, separated by spaces and terminated with a single new
line. All other output is written on standard error.

-- excerpt from man fuser on Solaris
cheers, drl
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command output to a variable.

With cut -c 8-13 myfile, I am getting some numeric value. In my shell script I am trying to assign something like this, var=cut -c 8-13 myfile But at the time of execution I am getting -c is not found. If I dont assign, then script executes well. Can we not simply use the value from one... (8 Replies)
Discussion started by: videsh77
8 Replies

2. UNIX Desktop Questions & Answers

problem while storing the output of awk to variable

Hi, i have some files in one directory(say some sample dir) whose names will be like the following. some_file1.txt some_file2.txt. i need to get the last modified file size based on file name pattern like some_ here i am able to get the value of the last modified file size using the... (5 Replies)
Discussion started by: eswarreddya
5 Replies

3. Shell Programming and Scripting

Redirecting output of a command to a file

Hi We are having a requirement where one shell script, say a.sh (which uses Java and connects to Oracle database using JDBC) keeps on running everytime. I created a wrapper (to check whether a.sh is running and if not then to start it) and scheduled it in the crontab. Now all the output from... (3 Replies)
Discussion started by: ankitgoel
3 Replies

4. Programming

Command output into a variable

Hi, with this command: cu -l /dev/ttyACM0 -s 9600 > name.txt I put the output of the port in a txt Is posible to do the same (or similar) in a var directly, inside a C program? cu -l /dev/ttyACM0 -s 9600 > variable ? I have trying this withs pipes, but i dont know how to... (6 Replies)
Discussion started by: daaran
6 Replies

5. Shell Programming and Scripting

Redirecting output that was redirected to variable and console

Hi all, I would like to store the output of a command in a variable and output it to the console at the same time. This is working fine using the following construct var=`command | tee /dev/tty` I use this in some scripts to display the output of the command on the console and, at the same... (2 Replies)
Discussion started by: script_man
2 Replies

6. Shell Programming and Scripting

Redirecting command output as well as commands

I have a Bourne Shell script that is normally run as a background job and redirects it's output to a file internally (using exec >>); I use "set -x" to capture each command which provides me with a nice shell execution log if it all goes to pieces. I now also need to be able to also run this as... (4 Replies)
Discussion started by: AncientCoder
4 Replies

7. Shell Programming and Scripting

date output store in variable problem

When I run following command date Output1 => Thu Sep 9 03:26:52 IST 2010 When I store in a varibale as a=`date` echo $a output2 => Thu Sep 9 03:27:02 IST 2010 The differnece is, it is trimming the space when I am storing the output in varibale. Output1 = Thu Sep 9 03:26:52 IST 2010... (2 Replies)
Discussion started by: pravincpatil
2 Replies

8. Shell Programming and Scripting

Redirecting command output to a file in a shell script

Hello All, I have some unique requirement. I have written a very lengthy script which calls number of resource script to execute a particular task. What I want is output of each command(called from main script and resource scripts) should go to a... (3 Replies)
Discussion started by: anand.shah
3 Replies

9. Linux

RHEL 6.3 - chage command not redirecting the output to console.

When i am issuing chage command, it reporting the output properly. But when i redirect the output, i am not getting the output in the mentioned path. chage -l root >> /tmp/chage.txt. I need to use this into the script to capture the data. I think its seems to be bug with RHEL 6.3. Same... (3 Replies)
Discussion started by: Srini.rk1983
3 Replies

10. Programming

Redirecting output to new file for command "perldoc perllocal"

Hi, I have to redirect output of the command "perldoc perllocal" to new file which contains all the perl module installed. Currently using perldoc perllocal >> mod_data This does not contain all perl modules installed locally on machine, and each character is doubled. Please... (3 Replies)
Discussion started by: asak
3 Replies
FUSER(P)						     POSIX Programmer's Manual							  FUSER(P)

NAME
fuser - list process IDs of all processes that have one or more files open SYNOPSIS
fuser [ -cfu ] file ... DESCRIPTION
The fuser utility shall write to standard output the process IDs of processes running on the local system that have one or more named files open. For block special devices, all processes using any file on that device are listed. The fuser utility shall write to standard error additional information about the named files indicating how the file is being used. Any output for processes running on remote systems that have a named file open is unspecified. A user may need appropriate privilege to invoke the fuser utility. OPTIONS
The fuser utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines. The following options shall be supported: -c The file is treated as a mount point and the utility shall report on any files open in the file system. -f The report shall be only for the named files. -u The user name, in parentheses, associated with each process ID written to standard output shall be written to standard error. OPERANDS
The following operand shall be supported: file A pathname on which the file or file system is to be reported. STDIN
Not used. INPUT FILES
The user database. ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of fuser: LANG Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of IEEE Std 1003.1-2001, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments). LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES . ASYNCHRONOUS EVENTS
Default. STDOUT
The fuser utility shall write the process ID for each process using each file given as an operand to standard output in the following for- mat: "%d", <process_id> STDERR
The fuser utility shall write diagnostic messages to standard error. The fuser utility also shall write the following to standard error: * The pathname of each named file is written followed immediately by a colon. * For each process ID written to standard output, the character 'c' shall be written to standard error if the process is using the file as its current directory and the character 'r' shall be written to standard error if the process is using the file as its root directory. Implementations may write other alphabetic characters to indicate other uses of files. * When the -u option is specified, characters indicating the use of the file shall be followed immediately by the user name, in parenthe- ses, corresponding to the process' real user ID. If the user name cannot be resolved from the process' real user ID, the process' real user ID shall be written instead of the user name. When standard output and standard error are directed to the same file, the output shall be interleaved so that the filename appears at the start of each line, followed by the process ID and characters indicating the use of the file. Then, if the -u option is specified, the user name or user ID for each process using that file shall be written. A <newline> shall be written to standard error after the last output described above for each file operand. OUTPUT FILES
None. EXTENDED DESCRIPTION
None. EXIT STATUS
The following exit values shall be returned: 0 Successful completion. >0 An error occurred. CONSEQUENCES OF ERRORS
Default. The following sections are informative. APPLICATION USAGE
None. EXAMPLES
The command: fuser -fu . writes to standard output the process IDs of processes that are using the current directory and writes to standard error an indication of how those processes are using the directory and the user names associated with the processes that are using the current directory. RATIONALE
The definition of the fuser utility follows existing practice. FUTURE DIRECTIONS
None. SEE ALSO
None. COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 FUSER(P)
All times are GMT -4. The time now is 03:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy