Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Why does bash sometimes refuse to accept my orders by simply starting a new line beginning with a greater-than sign instead of executing the command? Every press on enter adds a new line, and the only way to escape this seems to be hitting Ctrl+C.

As an example: a small command that I sometimes need to limit the fan speed of my laptop is not working anymore:

RegenbogenBook:Resources Vincent$ smc -k F0Mx -w $(python -c 'print hex(2800 << 2)[2:]’)
>
>
>

I have the impression that I'm only missing something really obvious, but this kind of basic thing is just not covered in any FAQs or accessible via search...

share|improve this question
2  
This can never worked, you are doing something different now. The problem is in the opening ' that doesn't get closed off. –  Anthon Dec 10 '14 at 15:45
2  
Those > are the secondary prompt (PS2) asking you for the rest of your command (here it expects at least a closing ' (not ) and closing the command substitution). –  Stéphane Chazelas Dec 10 '14 at 15:47

4 Answers 4

up vote 8 down vote accepted

You're probably cutting and pasting the command (or parts of it) from a document instead of typing it in manually. Usually this doesn't make any difference, but in this case, the second quote character was inserted as a "right single quotation mark" () instead of an "apostrophe" ('). The difference is subtle -- see this page for more details:

http://en.wikipedia.org/wiki/Quotation_mark_glyphs

The reason this probably happened is that when you first typed in the command to the document to save it for future reference, your word processor automatically converted the second apostrophe into a right single quotation mark. It does this to make the character look nicer on the screen, but bash doesn't recognize this character as a valid closing quote, so you run into the problem. It prints ">" to prompt for further input, because it still thinks the original quote has not been closed.

The fix is to change that character to an apostrophe -- just retype it manually into bash from the keyboard. And you can also correct it in your document so that future cut+pasting will work fine.

share|improve this answer
    
This is exactly what I did and what caused the problem. It works fine now and I also corrected it in my document. Thanks a lot for your sharp eyes! –  helplessuser Dec 10 '14 at 16:16
    
You're welcome! –  kartik_subbarao Dec 10 '14 at 16:28

Your last quote is a round one, so the string you are passing to python is not finished. You can see the difference in the syntactic coloration:

smc -k F0Mx -w $(python -c 'print hex(2800 << 2)[2:]’)

vs

smc -k F0Mx -w $(python -c 'print hex(2800 << 2)[2:]')
share|improve this answer

The > you are seeing is because the shell is still waiting on input. As fredtantini's answer stated you have not correctly closed your statement.

There are other times you'd see the secondary input prompt (called PS2 in Bash). Certain interactive commands such as mailx will use this to fill in email fields. You can close a secondary input prompt by sending EOF to the shell by pressing Ctrl+D.

share|improve this answer

Problem

As Everyone else has said, the OP has an unterminated string in your python statement. You confused a rounded quote with a single quote.


Intended Usage

Seeing as the OP didn't know about the Secondary Prompt, I wanted to show the OP an example taken from the Linux From Scratch - Version 7.6 with SystemD book, and explain how this works. This is how the prompt is used in most cases:

cat > version-check.sh << "EOF"
#!/bin/bash
# Simple script to list version numbers of critical development tools

export LC_ALL=C
bash --version | head -n1 | cut -d" " -f2-4
echo "/bin/sh -> `readlink -f /bin/sh`"
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-
bison --version | head -n1
if [ -e /usr/bin/yacc ];
  then echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";
  else echo "yacc not found"; fi

bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
diff --version | head -n1
find --version | head -n1
gawk --version | head -n1
if [ -e /usr/bin/awk ];
  then echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`";
  else echo "awk not found"; fi

gcc --version | head -n1
g++ --version | head -n1
ldd --version | head -n1 | cut -d" " -f2-  # glibc version
grep --version | head -n1
gzip --version | head -n1
cat /proc/version
m4 --version | head -n1
make --version | head -n1
patch --version | head -n1
echo Perl `perl -V:version`
sed --version | head -n1
tar --version | head -n1
xz --version | head -n1

echo 'main(){}' > dummy.c && g++ -o dummy dummy.c
if [ -x dummy ]
  then echo "g++ compilation OK";
  else echo "g++ compilation failed"; fi
rm -f dummy.c dummy

EOF

Reasoning

The only tool Linux from Scratch makes extensive use of is the Terminal. In order to make sure that the book breaks away from the host build version, the book instructs you to type all scripts and config files using the behavior the OP thought was a problem. The first line creates a here document that will have the name version-check.sh when finished. Below is a screenshot from a Cygwin Terminal of the completed script:

Cygwin Script without Text Editor

Notice that the script contains CR/LF's which create whitespace in the document and increase readability. Every CR/LF creates a new instance of >, and by the end at the EOF, all the >'s create the buffer that becomes version-check.sh.

share|improve this answer
1  
I appreciate the effort you put into this answer. Please note that the user's original command line contained a round single quote ’, rather than a tick `. The round single quote isn't on most keyboards. –  daveloyall Dec 10 '14 at 20:02
    
@depquid How would I fix my confusion? NVM, I'll fix it. daveloyall that key should be apostrophe. –  eyoung100 Dec 10 '14 at 22:14
    
@daveloyall It is I'm in Chromium, regardless I'll edit the answer again. –  eyoung100 Dec 10 '14 at 22:30
    
@daveloyall does it pass now? –  eyoung100 Dec 10 '14 at 22:35
    
Let us continue this discussion in chat. –  daveloyall Dec 10 '14 at 22:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.