0

I have a simple shell script to login as a normal user, and this normal user has a shell ready to switch into a user that has sudo privileges. However, I can't get it to work:

sshpass -p PASS ssh -t -o StrictHostKeyChecking=no user@host "sudo -s -u SUDOUSER;sudo cp -r "${STAGING}/${THEME}/*" /opt/themes/"${THEME}/.";exit;rm -rf "${STAGING}/*""

This logs me into the server fine and then switch into SUDOUSER but then it actually just stops there and prompts me as SUDOUSER on the host (basically logged me into SUDOUSER on the server and awaits command)

I need the script to run and return back to my originating terminal with cp and rm tasks completed.

Can someone please help?

Thanks

1 Answer 1

1

This seems largely a quoting problem. Try this:

sshpass -p PASS ssh -t -o StrictHostKeyChecking=no user@host \
    "sudo -s -u SUDOUSER '\
        cp -r \"${STAGING}/${THEME}/*\" /opt/themes/\"${THEME}/.\"; \
        rm -rf \"${STAGING}/*\"'"

I assume $STAGING and $THEME are variables in your local shell.

1
  • thanks, that was my problem, with quotes single and double mixing it up.. May 5, 2014 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .