Solved

Linux bash scripting

Posted on 2013-05-29
2
527 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39204338
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
ID: 39204349
thanks, I figured it was something dumb I didn't have, thanks for the help.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

705 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