Sponsored Content
Top Forums Shell Programming and Scripting problem redirecting output of command to variable Post 302223131 by nunovc on Friday 8th of August 2008 12:15:50 PM
Old 08-08-2008
solved!

I think that's just it! To explain in detail: when i execute

TATA=`fuser LockedFiles/deals.csv`

in the script, the part of the output of the command that would go to the Standard Output really goes into the variable, and the part of the output that would go to Standard Error is written in the screen. The first part of the output was actually empty ("") in the case i was running, and that's why the value in the variable was erased.

Duh!

Thanks Smilie
 

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(8)						      System Manager's Manual							  fuser(8)

NAME
fuser - Lists process IDs of processes that are using one or more files or file structures SYNOPSIS
/usr/sbin/fuser [-cfu] file ... [Tru64 UNIX] The following format shows extensions not included in the XCU specification for this utility: /usr/sbin/fuser [-cdfku] [-h] [-vH] file ... STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: fuser: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. FLAGS
Identifies file as a mount point. In this case, fuser reports on any files that are open in the mounted file system. Report any refer- enced files that have been deleted including the referencing PID and the block count for the file in 512 byte block units. Requests a report only for the specified files. If a specified file is a mount point, fuser reports only on that file, not on any files below it. [Tru64 UNIX] Suppresses column headings in fuser output when used with the -v flag. [Tru64 UNIX] Directs fuser to display information about its command-line options. [Tru64 UNIX] Directs fuser to send a SIGKILL signal to each process. Because this flag spawns a kill operation for each process, the kill messages may not show up immediately. Directs fuser to show the user login name, in parentheses, associated with each process ID. [Tru64 UNIX] Directs fuser to display results in verbose form. PARAMETERS
[Tru64 UNIX] Directs fuser to ignore previous flag settings for the next set of file parameters. The - operand allows you to apply differ- ent flags to different sets of files in the same command line. Specifies the pathname of the file or the mount point of the file system on which fuser reports. DESCRIPTION
The fuser utility writes to standard output the process IDs of processes that are running on the local system and have one or more files or file structures in use. The utility writes to standard error additional information about these resources that indicates how each resource is being used. If file identifies a block special device, fuser lists all processes using any file on that device. This utility does not display information about files for which you do not have the appropriate privileges. For information on many files, root privilege may be required. Furthermore, you must have appropriate privileges to use the -k flag. The utility uses the following format to write the process ID for each process using each file: "%d", process_id The fuser utility writes diagnostic messages to standard error. In addition, the utility writes the following information to standard error: The pathname of each file, immediately followed by a colon. For each process ID written to standard output, one of the following characters: If the process is using the file as its current directory. [Tru64 UNIX] If the process is using a memory-mapped file. [Tru64 UNIX] If the process is using the file as the parent of its current directory. If the process is using the file as its root directory. [Tru64 UNIX] If the process has the file open. [Tru64 UNIX] If the process is using the file as its controlling tty. [Tru64 UNIX] If the process is using the text file as an executable. If you specify the -u flag, characters indicating the use of the file are followed immediately by the user name, in parentheses, that corresponds to the process's real user ID. If the user name cannot be resolved from the process's real user ID, the process's real user ID is written instead of the user name. When standard output and standard error are directed to the same file, the utility intersperses output so that the file appears at the start of each line, followed by the process ID and the characters indicating file use. Then, if the -u option is specified, the utility writes the user name or user ID for each process that is using that file. The utility writes a newline character at the end of output for each file. ENVIRONMENT VARIABLES
The following environment variables affect this utility: Provides a default value for the locale variables that are unset or null. If LANG is unset or null, the corresponding value from the POSIX (C) locale is used. If any of the locale variables contain an invalid setting, the utility behaves as if none of the variables had been set. If set to a non-empty string value, overrides the values of all the other locale variables. Specifies the locale used to interpret sequences of bytes of text data as characters (for example, determines whether arguments contain single-byte or multibyte characters). Specifies the locale that affects the format and contents of diagnostic messages written to standard error. Determines the location of message catalogs for the processing of LC_MESSAGES. NOTES
[Tru64 UNIX] The fuser utility may not report on processes that begin using a file while the utility is running. Furthermore, processes that fuser reports are using a file may have stopped using it while the utility was running. EXAMPLES
The following command lists the process IDs of processes using the /etc/hosts file: fuser /etc/hosts The following command writes to standard output the process IDs of processes that are using the current directory. The command writes to standard error an indication of how those processes are using the directory and the user names associated with those processes. fuser -fu . EXIT VALUES
The fuser utility returns the following exit values: Successful completion. An error occurred. RELATED INFORMATION
Functions: fuser(2), kill(2) delim off fuser(8)
All times are GMT -4. The time now is 03:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy