You do not need to do the filtering on the remote host. Just do the ps remotly and the rest locally :
num=`ssh userName@remoteBox 'ps -ef' | grep userName | grep -i processName | grep -v grep | awk '{print $2 }'`
--------------------
Denis
What are the values for @last4months[0..3] and $rpt_month ?
Could it be possible that $rpt_month equals one of the last4months ?
--------------------
Denis
You could try:
sed 's/^"//;s/"$//' | awk -F '"?,"?'
in the first example given by p5wizard.
The sed suppress any " at start or end of line and the -F in awk allowed for optional " before and after the comma.
This simple trick would not work if there is any comma or escaped quotes inside the...
No need to backquote the ls: you don't want the output of ls, just its exit code (ls returns an error if a file does not exist).
Just remove the standard and error outputs and check the return code (it's what if do):
if ls *.log >/dev/null 2>&1; then
: # Here at least one .log file exists...
Use eval !
The command export has an (unwanted) side effect: it exports the variables.
Besides, eval also allows you to get/use the values using constructed variable names:
eval echo \$CLIENT${COUNT}
--------------------
Denis
... unless you put a dash '-' just after the '<<'.
In this case all TABs (and only TABs) are stripped from the start of the following lines before they are used (either for checking against the 'EndOfHereDocument' string or as input for your command)
for arg in "$@"
do
ftp -n -i -v <<-SCRIPT...
If not for the speed problem you speak of in your other thread thread822-989438 (and I do not know if this is so much un issue), it could be so much simpler with tar.
You could directly use the fileList.txt
# backup
(cd /; tar cf - -T fileLst.txt) | (cd /backuploc; tar xf -)
# restore
(cd...
#!/usr/bin/perl -w
use warnings;
use strict;
use locale;
open FILE1, "file1.ans" or die;
open FILE2, "file2.ans" or die;
my %orig;
my %orig_from_lc;
my %to_be_used;
while (<FILE1>) {
chomp;
my ($orig, $punct)=split /\t/;
$orig{$orig}=$punct;
$orig_from_lc{lc $orig} = $orig...
Some reflexions about strcmp returning <0, =0, >0 instead of -1, 0, 1.
As Salem said: both results are consistent, yes. But looking for positive or negative instead of 1 and -1 is more generic and will be true for all implementations. When in doubt stick to the manual.
How many times did I...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.