Solved

Linux bash scripting

Posted on 2013-05-29
2
511 Views
Last Modified: 2013-05-29
Can someone help me with this issue Im having, I have a script to deploy new users and create a new group that will have sudo rights. I have the script ready and Im having issues with one line as per below
echo "## SSS user group sudo rights >> /etc/sudoers" & echo "%sss ALL=(ALL) ALL" >> /etc/sudoers

if I execute this locally it works fine but if I have it executed from an ssh session on a script I get an error like below

E420S ag # ssh 172.28.78.86 echo "%sss ALL=(ALL) ALL" >> /etc/sudoers
bash: -c: line 0: syntax error near unexpected token `('
bash: -c: line 0: `echo %sss ALL=(ALL) ALL'

appreciate any help
0
Comment
Question by:atorex
2 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
Comment Utility
ssh swallows the quotes, so you must escape the parentheses.

Besides that, you'll have to place the output redirection inside the quotes, otherwise you're going to create a local file!


ssh 172.28.78.86 "echo %sss ALL=\(ALL\) ALL >> /etc/sudoers "
0
 

Author Closing Comment

by:atorex
Comment Utility
thanks, I figured it was something dumb I didn't have, thanks for the help.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now