d_asselin
asked on
Shell script
Hi
I have a script that perform security settings on Solaris servers
And I need to modify it so that I can import the results to a mysql db
It is a very long script separated into many modual.
What I need to do is echo the output of individual command and log them
To a file with notations.
Here is a example of one loop (there a several)
echo Enable stack protection
if [ ! "`grep noexec_user_stack /etc/system`" ]; then
cat <<END_CFG >>/etc/system
* Attempt to prevent and log stack-smashing attacks
set noexec_user_stack = 1
set noexec_user_stack_log = 1
cat /etc/system | grep noexec_user_stack >> /var/tmp/`hostname`-securi ty-setup.l og
cat /etc/system | grep noexec_user_stack_log >> /var/tmp/`hostname`-securi ty-setup.l og
END_CFG set noexec_user_stack=1
fi
and this sends to a log file in thi format
set noexec_user_stack=1
set noexec_user_stack_log=1
But what I need is this
“ test-num“,”set noexec_user_stack =1”,” Setting is noexec_user_stack=1”
I have a script that perform security settings on Solaris servers
And I need to modify it so that I can import the results to a mysql db
It is a very long script separated into many modual.
What I need to do is echo the output of individual command and log them
To a file with notations.
Here is a example of one loop (there a several)
echo Enable stack protection
if [ ! "`grep noexec_user_stack /etc/system`" ]; then
cat <<END_CFG >>/etc/system
* Attempt to prevent and log stack-smashing attacks
set noexec_user_stack = 1
set noexec_user_stack_log = 1
cat /etc/system | grep noexec_user_stack >> /var/tmp/`hostname`-securi
cat /etc/system | grep noexec_user_stack_log >> /var/tmp/`hostname`-securi
END_CFG set noexec_user_stack=1
fi
and this sends to a log file in thi format
set noexec_user_stack=1
set noexec_user_stack_log=1
But what I need is this
“ test-num“,”set noexec_user_stack =1”,” Setting is noexec_user_stack=1”
ASKER
Yes and no
I still need to insert in to the log some fields like so
“ test-num“,”set noexec_user_stack =1”,” Setting is noexec_user_stack=1”
to break it down
I still need to insert in to the log some fields like so
“ test-num“,”set noexec_user_stack =1”,” Setting is noexec_user_stack=1”
Single quote beginning of line “,” field separator “ end of line
“ Required setting”,” actual setting"
I still need to insert in to the log some fields like so
“ test-num“,”set noexec_user_stack =1”,” Setting is noexec_user_stack=1”
to break it down
I still need to insert in to the log some fields like so
“ test-num“,”set noexec_user_stack =1”,” Setting is noexec_user_stack=1”
Single quote beginning of line “,” field separator “ end of line
“ Required setting”,” actual setting"
How about something like:
grep noexec_user_stack /etc/system >/dev/null 2>&1
if [ "$?" != "0" ] ; then
echo "* Attempt to prevent and log stack-smashing attacks" >>/etc/system
echo set noexec_user_stack=1 >>/etc/system
echo set noexec_user_stack_log=1 >>/etc/system
grep noexec_user_stack= /etc/system >>/var/tmp/`hostname`-secu rity-setup .log
grep noexec_user_stack_log= /etc/system >>/var/tmp/`hostname`-secu rity-setup .log
echo "insert anything else you like into the log here" >>/var/tmp/`hostname`-secu rity-setup .log
fi
grep noexec_user_stack /etc/system >/dev/null 2>&1
if [ "$?" != "0" ] ; then
echo "* Attempt to prevent and log stack-smashing attacks" >>/etc/system
echo set noexec_user_stack=1 >>/etc/system
echo set noexec_user_stack_log=1 >>/etc/system
grep noexec_user_stack= /etc/system >>/var/tmp/`hostname`-secu
grep noexec_user_stack_log= /etc/system >>/var/tmp/`hostname`-secu
echo "insert anything else you like into the log here" >>/var/tmp/`hostname`-secu
fi
ASKER
That will not work
I think I’m not explaining myself properly
It is not a question of inserting something in a log! But inserting text into a single
I need the results of a command plus some text in a single line of text
Beginning with a quote and fields separated commas
Line like so
“Hostname”,”“Text1 here”,” text2 here”,” result here”
“ Field1 “,” Field2 “,” field3 “,” field4”
Dan
I think I’m not explaining myself properly
It is not a question of inserting something in a log! But inserting text into a single
I need the results of a command plus some text in a single line of text
Beginning with a quote and fields separated commas
Line like so
“Hostname”,”“Text1 here”,” text2 here”,” result here”
“ Field1 “,” Field2 “,” field3 “,” field4”
Dan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This works very well
Very much very much appreciated
Dan
Very much very much appreciated
Dan
grep noexec_user_stack /etc/system >/dev/null 2>&1
if [ "$?" != "0" ] ; then
echo "* Attempt to prevent and log stack-smashing attacks" >>/etc/system
echo set noexec_user_stack=1 >>/etc/system
echo set noexec_user_stack_log=1 >>/etc/system
grep noexec_user_stack= /etc/system >>/var/tmp/`hostname`-secu
grep noexec_user_stack_log= /etc/system >>/var/tmp/`hostname`-secu
fi