LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   why it complains: Unmatched ". (https://www.linuxquestions.org/questions/linux-newbie-8/why-it-complains-unmatched-4175655287/)

julian16 06-06-2019 05:08 PM

why it complains: Unmatched ".
 
On a RedHat 7, it complains

Unmatched ".

when I ran this command line:

sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""


on both tcsh and bash. .. I wonder what was wrong? How can I get over this?

Thanks in advance! julian

scasey 06-06-2019 07:11 PM

Quote:

Originally Posted by julian16 (Post 6002918)
On a RedHat 7, it complains

Unmatched ".

when I ran this command line:

Code:

sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""

on both tcsh and bash. .. I wonder what was wrong? How can I get over this?

Thanks in advance! julian

Please use code tags when posting code or output.

You have double quotes within double quotes.
Try changing the outermost quotes to single quotes.

julian16 06-06-2019 09:50 PM

Thank you for the reply.

If I change outer pair of double quotes to single quotes, then it brings up problems with other single quotes in the command line, causing
Quote:

Error: unexpected '/'
I just got over this simply by su to root, fire up an R, and ran the command line within the R environment.

I would like to follow this problem because it's copied command line from a tutorial, which imply it worked for many others. I just wonder why it didn't work in my bash/tcsh on RH7.

pan64 06-07-2019 01:43 AM

first of all you do not (must not) use sudo and su together, most probably sudo is the [only] one you need.
Next: if you have a situation like this (quotation problems) try to write a working shell script (without sudo) and finally just sudo <your script> will do the job.

It is not bash/tcsh and/or RH7, but incorrectly formulated command. (probably you made a mistake when you copied it from that tutorial). By the way which tutorial is it?

finally you may find shellcheck.net useful to catch this issue.

grail 06-07-2019 09:24 AM

I agree with pan64's suggestion of placing in a script, but if you do still want to use varying types of quotes, I would suggest you look into heredocs

ehartman 06-07-2019 10:41 AM

Quote:

Originally Posted by scasey (Post 6002932)
Try changing the outermost quotes to single quotes.

Then, as the line is already using single quotes too, he would have single quotes within single quotes, not a real improvement :-(

scasey 06-07-2019 02:03 PM

Quote:

Originally Posted by ehartman (Post 6003116)
Then, as the line is already using single quotes too, he would have single quotes within single quotes, not a real improvement :-(

I see I didn't study it carefully enough. I was going for '..."...'...'..."...' - such that the second set of singles were inside the doubles, which should be OK, theoretically.


All times are GMT -5. The time now is 11:39 AM.