Unix/Linux Go Back    


Red Hat Red Hat is the world's leading open source technology solutions provider with offerings including Red Hat Enterprise Linux (RHEL), Fedora, open source applications, security and systems management, virtualization, and Services Oriented Architecture (SOA) solutions.

Use variable that needs "" in remote ssh command.

Red Hat


Tags
grep, remote ssh, variable

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 1 Week Ago
toor13 toor13 is offline
Registered User
 
Join Date: Jan 2011
Last Activity: 18 August 2017, 4:06 PM EDT
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
RedHat Use variable that needs "" in remote ssh command.

I want to use the below but since the date has a space it doesn't grep exactly what's needed. I need to keep the quotes around the variable when it passes it. I need the quotes around $DATE2 just to recognize the variable. Thanks in advance for any help given.


Code:
D=`date +%d`
DN=`echo -n $D | wc -c`
if [ $DN = 1 ]; then
  DATE2=`date "+%b  %d"`
elif [ $DN = 2 ]; then
  DATE2=`date "+%b %d"`
fi

FL=`ssh -q $SERVER grep "$DATE2" /var/log/secure | grep Failed | grep -Po "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | sort | uniq -c | tr "\n" " "`


Moderator's Comments:
Use variable that needs "" in remote ssh command. Please use CODE tags as required by forum rules!

Last edited by RudiC; 1 Week Ago at 05:38 PM.. Reason: Added CODE tags.
Sponsored Links
    #2  
Old Unix and Linux 1 Week Ago
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 19 August 2017, 7:07 AM EDT
Location: San Jose, CA, USA
Posts: 10,463
Thanks: 533
Thanked 3,660 Times in 3,123 Posts
What happens with:

Code:
FL=`ssh -q $SERVER grep "\"$DATE2\"" /var/log/secure | grep Failed | grep -Po "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | sort | uniq -c | tr "\n" " "`

Sponsored Links
    #3  
Old Unix and Linux 1 Day Ago
toor13 toor13 is offline
Registered User
 
Join Date: Jan 2011
Last Activity: 18 August 2017, 4:06 PM EDT
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
That worked.

Can't believe I didn't try that. Needed a fresh set of eye. Thanks for the help.
    #4  
Old Unix and Linux 1 Day Ago
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 18 August 2017, 6:48 PM EDT
Location: Saskatchewan
Posts: 22,336
Thanks: 1,116
Thanked 4,216 Times in 3,899 Posts
All of that could likely be performed with one awk and one sort if we knew what you were actually doing, too.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using "mailx" command to read "to" and "cc" email addreses from input file asjaiswal UNIX for Dummies Questions & Answers 2 10-11-2014 09:32 PM
awk command to replace ";" with "|" and ""|" at diferent places in line of file shis100 Shell Programming and Scripting 7 03-16-2011 08:59 AM
Remote script skips "read" command Bubnoff Shell Programming and Scripting 8 06-17-2010 03:23 PM
store the output of "find" command in a variable? punitpa Shell Programming and Scripting 4 08-04-2009 07:21 AM
Running command "md5" on remote host not working. ynilesh UNIX for Advanced & Expert Users 1 02-01-2008 07:15 AM



All times are GMT -4. The time now is 04:37 PM.