Save the output of the command run as other user


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Save the output of the command run as other user
# 8  
Old 02-13-2010
What operations? You could use awk instead of tail to achieve that.
# 9  
Old 02-13-2010
Quote:
Originally Posted by Franklin52
What operations? You could use awk instead of tail to achieve that.
For example i have a command whose output is like this:

Code:
# PARTITION | MASTER_ROLE |STATE_M|STATE_S|MASTER_ATOMICID | SLAVE_ATOMICID | DIFF_ATOMICID |
#-----------|-------------|-------|-------|----------------|----------------|---------------|
 acc1  |     PRIMARY |VALID  |VALID  |     1718408937 |     1718408861 |            76 |
 acc2  |     PRIMARY |VALID  |VALID  |     1718408937 |     1718408861 |            76 |
 acc3  |     PRIMARY |VALID  |VALID  |     1718408937 |     1718408861 |            76 |
 acc4  |     PRIMARY |VALID  |VALID  |     1718408937 |     1718408861 |            76 |
 acc5  |     PRIMARY |VALID  |VALID  |     1701569594 |     1701569423 |           171 |
 acc6  |     PRIMARY |VALID  |VALID  |     1701569594 |     1701569423 |           171 |
 acc7  |     PRIMARY |VALID  |VALID  |     1701569594 |     1701569423 |           171 |
 acc8  |     PRIMARY |VALID  |VALID  |     1701569594 |     1701569423 |           171 |
 acc9  |     PRIMARY |VALID  |VALID  |     1749603110 |     1749603038 |            72 |

Now if this value is stored in variable "check" then how would i delete the first few un-necessary lines, cut all the columns except last column and check if the value isn't greater than 500.

These type of operations i have to perform. Please suggest some way. Thanks
# 10  
Old 02-13-2010
Do you want all the selected values of the last column in your variable in this case?
# 11  
Old 02-13-2010
Quote:
Originally Posted by Franklin52
Do you want all the selected values of the last column in your variable in this case?
Yes, and check if any value from the last column is greater than 500.
# 12  
Old 02-13-2010
Can you explain what you're trying to achieve with your script instead of asking how to use which command?

There could be another (better) approach to achieve your task.
# 13  
Old 02-13-2010
Quote:
Originally Posted by Franklin52
Can you explain what you're trying to achieve with your script instead of asking how to use which command?

There could be another (better) approach to achieve your task.

Well I am performing some system checks, and the system is being used in a live GSM network. The command i quoted in last is one of the checks. I've to check if the value of last column isn't greater than 500. Because if it is, then we got some serious issues regarding synchronization. and i am writing the script for these checks. And the only problem is with some commands i have to run as other user like user1.

Just point me in the right direction. Thank you very much spending your time on this.
# 14  
Old 02-13-2010
Quote:
Originally Posted by suhail.sadaqat
Well I am performing some system checks, and the system is being used in a live GSM network. The command i quoted in last is one of the checks. I've to check if the value of last column isn't greater than 500. Because if it is, then we got some serious issues regarding synchronization. and i am writing the script for these checks. And the only problem is with some commands i have to run as other user like user1.

Just point me in the right direction. Thank you very much spending your time on this.
And what to do if you have more then one value > 500? In that case you'll get several lines.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question