Sponsored Content
Top Forums Shell Programming and Scripting Save the output of the command run as other user Post 302394893 by suhail.sadaqat on Saturday 13th of February 2010 09:14:11 AM
Old 02-13-2010
Quote:
Originally Posted by Franklin52
Code:
check=`su - user1 -c "pwd" | tail -1`

Yes you are right Franklin, but this works only for the command having 1 line output like "pwd". I have to run other commands whose output length may vary. so how do i do some operations on the variable ("check" in this case)?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run a command with some other user id

Hi Say I am running a script using my user id csaha. How can I run any specific command in the same sctipr using any other user id (say root). Definitely I have the password of root. Any idea how the same can be achieved ??? Example: I need to run a script using my id (csaha) only on... (4 Replies)
Discussion started by: csaha
4 Replies

2. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

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)
Discussion started by: satimis
7 Replies

3. Shell Programming and Scripting

to save output of a command in hash variable

Hi all, is it possible to save the output of a unix command executed in perl to be saved in hash variable.. like i have the command `find $mypath ! -user mainuser -printf \"\%u \%h\\n\"`; this will print all the users other than mainuser with their paths. so is possible to capture... (2 Replies)
Discussion started by: saapa
2 Replies

4. UNIX for Dummies Questions & Answers

how to save the output of command in tcl/expect

hi, everyone: I just wonder how to save the output of command, I mean everything, save as a string into a variable. another question is I try to ls the details of a directory, but it works in the shell, not in the script. for example code: ls -ltr *se100* | grep ^- | tail -1 | awk '... (1 Reply)
Discussion started by: allenxiao7
1 Replies

5. Shell Programming and Scripting

Save cURL verbose output to file or do it like browser "save as.."

hi there ! i have exactly the same problem like this guy here https://www.unix.com/shell-programming-scripting/127668-getting-curl-output-verbose-file.html i am not able to save the curl verbose output.. the sollution in this thread (redirecting stderr to a file) does not work for me.... (0 Replies)
Discussion started by: crabmeat
0 Replies

6. Shell Programming and Scripting

how to save an output of a command in a variable

Hi, in shell script, i have the command swstart -p which returns an output. i want to store the output of this command into a variable. how i can do that excerpt from the script #!/usr/bin/ksh # # # # Program: swstart -p # # Description: Starts the sentinels on Slave server ... (4 Replies)
Discussion started by: lookinginfo
4 Replies

7. Shell Programming and Scripting

Reading ls -l output line by line awk the user name and su user to run commands

Using ksh on AIX what I am trying to do is to read the ls -l output from a file in a do while loop line by line. Extract the user name(3rd field) and the directory/file name(9th field) using awk and save them into variables. su -c to the user and change directory/file permisions to 777. Script I... (13 Replies)
Discussion started by: zubairom
13 Replies

8. Shell Programming and Scripting

Save value from output of Corestat and save in a list for each core

I am trying to modify the "corestat v1.1" code which is in Perl.The typical output of this code is below: Core Utilization CoreId %Usr %Sys %Total ------ ----- ----- ------ 5 4.91 0.01 4.92 6 0.06 ... (0 Replies)
Discussion started by: Zam_1234
0 Replies

9. Shell Programming and Scripting

How to execute command remotely as sudo and save the output locally?

Hello , I am trying to run a NetBackup command in remote server. Also this command can only be run by root so I am using sudo . Also I want the output of the command locally in a file. The below command asked for password , ran successfully and showed Output on my local server screen ... (2 Replies)
Discussion started by: rahul2662
2 Replies

10. Shell Programming and Scripting

Run sql query in shell script and output data save as delimited text

I want to run sql query in shell script and output data save as delimited text (delimited text would be comma) Code: SPOOL_FILE=/pgedw/dan.txt SQL=/pgedw/dan.sql sqlplus -s username/password@myhost:port/servicename <<EOF set head on set COLSEP , set linesize 32767 SET TRIMSPOOL ON SET... (8 Replies)
Discussion started by: Jaganjag
8 Replies
MTAIL(1)							   User Commands							  MTAIL(1)

NAME
mtail - tail variant designed for web developers monitoring logfiles SYNOPSIS
mtail [options] <file>... DESCRIPTION
MonkeyTail allows a user to tail multiple files on both local and remote hosts and clearly marks inactivity by putting 5 newlines in the output whenever a pause in output over 3 seconds is detected. MonkeyTail is implemented a fairly simple wrapper script around standard tail, ssh, and sudo. OPTIONS
-q Quiet mode --quiet " " -n Output the last N lines of each file before tailing (defaults to 0) <file>... Files to tail. These can specified in the following ways: @<groupname> - expands the group (from .mtailrc) to a list of files to tail <filename> - tails a local file. +<filename> - attempts to sudo and tail a local file (will prompt for pwd if required). <remotehost>:<filename> - attempts to invoke tail via ssh on a remote host. +<remotehost>:<filename> - attempts to invoke sudo tail via ssh on a remote host (will prompt for pwd if required). SEE ALSO
mtailrc(5), tail(1) AUTHOR
Martyn Smith <martyn@dollyfish.net.nz> mtail May 2008 MTAIL(1)
All times are GMT -4. The time now is 01:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy