Not retrieving value correctly in unix

celtician
celtician used Ask the Experts™
on
The next sentence is not returing the value it should get:


FROM2= 0;
(ssh machine2 "cat /var/log/syslog* | grep -i \"to=<a@server.com>\" | grep -i sent | grep \"$MONTH \" | cut -c4-6 | grep \" $day_y\" | wc -l") >> $FROM2
echo $FROM2;

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ozo
Most Valuable Expert 2014
Top Expert 2015

Commented:
What value is it returning, and what value should it get?
Did you really want those \?
Did you mean echo or cat?
Topic Advisor
Most Valuable Expert 2016
Commented:
Try:

FROM2=$(ssh...)
Top Expert 2007

Commented:
Assuming you want
FROM2=$(ssh machine2 "cat /var/log/syslog* | grep -i \"to=<a@server.com>\" | grep -i sent | grep \"$MONTH \" | cut -c4-6 | grep \" $day_y\" | wc -l") 
echo $FROM2

Open in new window

Author

Commented:
It worked, i only wanted to retrive the value, its an integer.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial