Sponsored Content
Full Discussion: Ssh with awk
Top Forums Shell Programming and Scripting Ssh with awk Post 302756055 by PikK45 on Tuesday 15th of January 2013 05:18:04 AM
Old 01-15-2013
In that case,

Code:
var="/tmp/conf-1 servers=lpar1 lpar2 lpar3"
 
echo $var | sed 's/=/ /g' | awk '{for(i=3;i<=NF;i++){print "ssh -q "$i" mount|grep "$1}}'

This should work Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk using ssh variable?

I have a file named Atoms that has a list of atoms listed vertically, like: O C Na etc. There is a variable number of them. I want to count their occurences in another file. I want to do this by saving each atom as a variable, preferabbly in an associative array, then counting how... (3 Replies)
Discussion started by: RisingSun
3 Replies

2. Shell Programming and Scripting

Passing awk through ssh help

First off we have hundreds of webservers in our farm that we sometimes have to collect logs for customers. Thing is the script that I currently am working on doesnt like my awk commands via ssh. I am very novice at best so all help would be greatly appreciated. ssh a$active "awk... (9 Replies)
Discussion started by: gbarnes
9 Replies

3. Shell Programming and Scripting

setting a variable, using SSH and awk?

hi there I am trying to get a value from a remote machine into a local variable. To get this value i want to use awk but im having trouble getting it to run, am i escaping in the right places here and using the right quotes (i must have tried a million combinations :() # VAR=`ssh server1... (5 Replies)
Discussion started by: hcclnoodles
5 Replies

4. Shell Programming and Scripting

awk - skip x lines and ssh

Im trying to ssh to a remote machine to grep 'x info' *.log and Im able to get the grep output as expected but "after" the policies (1st 14 lines) - I need to skip the first 14 lines. Its SunOS. Plz help??? (1 Reply)
Discussion started by: anthonyraj75
1 Replies

5. Shell Programming and Scripting

awk: skip x lines and ssh

Im trying to ssh to a remote machine to grep 'x info' *.log and Im able to get the grep output as expected but "after" the policies (1st 14 lines) - I need to skip the first 14 lines. Its SunOS. Plz help??? (7 Replies)
Discussion started by: anthonyraj75
7 Replies

6. Shell Programming and Scripting

SSH and AWK Scripting

I am trying to put an awk command in ssh, for example: ERRCOUNT=`ssh -n $HOST "ps -ef | grep .job | grep -v grep | grep -v alert_jobs_still_running |wc -l"` From korn shell prompt this works: awk '/^Jul 12 16/ {print $0}' /u01/app/oracle/jobs/adhoc/test.dat | wc -l My data file:... (3 Replies)
Discussion started by: bradyd
3 Replies

7. Shell Programming and Scripting

awk pattern matching on ssh

Hi folks, i am trying to filer some log file using awk command. When i try it on remote server, it can show the result. awk '$1=="2012-10-29" && $4==17353' somelogfile But when i try to execute it from ssh, it cannot show the same result. ssh someserver "awk '\$1=="2012-10-28" &&... (7 Replies)
Discussion started by: howielim
7 Replies

8. Shell Programming and Scripting

awk syntax error with ssh

I am attempting to ssh to a server and grab the line from /etc/group if it contains a specific GID. Example line from /etc/group: mysql:!:64600:mysql Run locally on <host>: # awk -F: '$3 == 64600 {print $1}' /etc/group mysql Attempt to ssh to <host> and execute: # ssh <host>... (3 Replies)
Discussion started by: port43
3 Replies

9. Shell Programming and Scripting

Query on executing awk using SSH

Hi All, Im trying to find the count of process running on remote server using SSH. Below command dosen't work. ssh -q user@host "ps -ef | grep "pattern" | grep -v 'grep' | awk '{print $2}'|wc -l" But below command works. ssh -q user@host "ps -ef | grep "pattern" | grep -v... (1 Reply)
Discussion started by: Girish19
1 Replies

10. Shell Programming and Scripting

awk over ssh

for pics in $(su - admin -c 'ssh kitchen "(cat /lister/filer1/volz/camera/Pictures\ Lists/Arizona/Photoy.txt|gawk '{print $1}')"'); do echo $pics; done output: missing } This is a list of pictures. I am trying to get the first column. The command works fine, as long as I don't use the awk... (5 Replies)
Discussion started by: newbie2010
5 Replies
SUBSTR_REPLACE(3)							 1							 SUBSTR_REPLACE(3)

substr_replace - Replace text within a portion of a string

SYNOPSIS
mixed substr_replace (mixed $string, mixed $replacement, mixed $start, [mixed $length]) DESCRIPTION
substr_replace(3) replaces a copy of $string delimited by the $start and (optionally) $length parameters with the string given in $replace- ment. PARAMETERS
o $string - The input string. An array of strings can be provided, in which case the replacements will occur on each string in turn. In this case, the $replacement, $start and $length parameters may be provided either as scalar values to be applied to each input string in turn, or as arrays, in which case the corresponding array element will be used for each input string. o $replacement - The replacement string. o $start - If $start is positive, the replacing will begin at the $start'th offset into $string. If $start is negative, the replacing will begin at the $start'th character from the end of $string. o $length - If given and is positive, it represents the length of the portion of $string which is to be replaced. If it is negative, it rep- resents the number of characters from the end of $string at which to stop replacing. If it is not given, then it will default to strlen( $string ); i.e. end the replacing at the end of $string. Of course, if $length is zero then this function will have the effect of inserting $replacement into $string at the given $start offset. RETURN VALUES
The result string is returned. If $string is an array then array is returned. EXAMPLES
Example #1 Simple substr_replace(3) examples <?php $var = 'ABCDEFGH:/MNRPQR/'; echo "Original: $var<hr /> "; /* These two examples replace all of $var with 'bob'. */ echo substr_replace($var, 'bob', 0) . "<br /> "; echo substr_replace($var, 'bob', 0, strlen($var)) . "<br /> "; /* Insert 'bob' right at the beginning of $var. */ echo substr_replace($var, 'bob', 0, 0) . "<br /> "; /* These next two replace 'MNRPQR' in $var with 'bob'. */ echo substr_replace($var, 'bob', 10, -1) . "<br /> "; echo substr_replace($var, 'bob', -7, -1) . "<br /> "; /* Delete 'MNRPQR' from $var. */ echo substr_replace($var, '', 10, -1) . "<br /> "; ?> Example #2 Using substr_replace(3) to replace multiple strings at once <?php $input = array('A: XXX', 'B: XXX', 'C: XXX'); // A simple case: replace XXX in each string with YYY. echo implode('; ', substr_replace($input, 'YYY', 3, 3))." "; // A more complicated case where each replacement is different. $replace = array('AAA', 'BBB', 'CCC'); echo implode('; ', substr_replace($input, $replace, 3, 3))." "; // Replace a different number of characters each time. $length = array(1, 2, 3); echo implode('; ', substr_replace($input, $replace, 3, $length))." "; ?> The above example will output: A: YYY; B: YYY; C: YYY A: AAA; B: BBB; C: CCC A: AAAXX; B: BBBX; C: CCC NOTES
Note This function is binary-safe. SEE ALSO
str_replace(3), substr(3), String access and modification by character. PHP Documentation Group SUBSTR_REPLACE(3)
All times are GMT -4. The time now is 07:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy