I had to do a reinstall of my linux system due to a faulty ssd, and have a problem with a install.sh script.The said script is included in with lcd files. which I downloaded from github.
It is a simple script which runs a realtime clock on a pi zero with an lcd screen.
When I run ./install.sh, it fails at ./install.sh: line 34: syntax error: unexpected end of file.
I don't know what the syntax should be here;
These are the last 4 lines in the script, and if I count the spaces then:
echo "Should be now all finished. Please press any key to now reboot. After rebooting run" echo "'sudo python demo_lcd.py' from this directory" read -n1 -s
Didn't find your answer? Ask the community — no account required.
A
alister
R
RobH
O
Ottavio Caruso
There's no line 34. Maybe the file is corrupted. How did you download the script? Did you use git?
Ottavio Caruso
M
Martin Gregorie
L
Lew Pitcher
[snip]
As others have suggested, the contents and origin of your install.sh script are in question. The best choice is to follow up on that, and obtain a valid install.sh script.
Failing that, you might try more diagnosis on the current install.sh script. You might try some simple shell debugging techniques:
1) Use the shell to interpret, but not execute, the script by turning on the -n shell option. This will syntax-check the script without allowing it to perform any operations. For example: sh -n ./install.sh
2) Use the shell to execute the script while displaying the unexpanded shell commands to stdout, by turning on the -v option. This permits you to see exactly the script lines as they are read. For example: sh -v ./install.sh
3) Use the shell to execute the script while displaying the expanded shell commands to stdout, by turning on the -x option. This permits you to see the exact content of the executed lines. For example: sh -x ./install.sh
Note: the -n, -v and -x option may not be available in all shell interpreters. If install.sh is a POSIX shell script, you may execute it with bash, which does support these options.
HTH
Lew Pitcher
"In Skills, We Trust"
D
Dennis Lee Bieber
On Wed, 30 Sep 2020 15:36:53 +0100, RobH declaimed the following:
Well -- since there are only 33 lines IN that file... I'd propose that you have some noise line (not line noise) in your copy. An EOF character, or wrong line ending.
formatting link
If you have an editor that shows non-printable characters (hexdump?) see if there is something that doesn't correlate to the visible text.
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
R
RobH
I just downloaded the files from Github, using a download button, but that is not there now???
R
RobH
Yes you are correct in that there is only 33 lines in that file.
I don't have an editor which shows non-printable characters.
Even after copying and pasting the 33 line script from your link, it still gives the same error message for line 34: ./install.sh: line 34: syntax error: unexpected end of file.
R
RobH
Running the read -nl -s in a terminal, just hangs, as it waiting for some other command maybe
O
Ottavio Caruso
That's not how you do it. You either checkout from Github:
git clone
formatting link
or download the tarball and extract it:
formatting link
Ottavio Caruso
T
Theo
Post the output of 'hexdump -C install.sh | tail' (install bsdmainutils package if you don't have hexdump)
My money is that there's a carriage return ('0d' in hexdump) in there somewhere - has the file been anywhere near Windows? For example, if it was on a file share and opened by a Windows machine.
Theo
L
Lew Pitcher
ITYM "read -n1 -s" (note that the character following the -n is a "digit one" (1) not a "lowercase letter L" (l) )
No, it's waiting for your input. It's the equivalent to "Hit any key to continue", albeit a bit sparse (The author could have written read -n1 -s -p "Hit any key to continue" )
For the "read" builtin, "One line is read from the standard input". The -n1 causes "read" to return after reading 1 character The -s causes "read" to not echo the consumed character back to the terminal.
Lew Pitcher
"In Skills, We Trust"
A
A. Dumas
No. If you want just a single file and you don't know about git, definitely don't try that. Click the "Raw" button and save the output of that. Either via copy/paste from the browser or using wget from the terminal with the URL of that raw file.
R
RobH
Running the above commands :
rob@rob-Z97:~/Pi_lcd/lcd-master$ sh -n ./install.sh ./install.sh: 34: ./install.sh: Syntax error: end of file unexpected (expecting "then")
rob@rob-Z97:~/Pi_lcd/lcd-master$ sh -n ./install.sh ./install.sh: 34: ./install.sh: Syntax error: end of file unexpected (expecting "then")
rob@rob-Z97:~/Pi_lcd/lcd-master$ sh -x ./install.sh ./install.sh: 34: ./install.sh: Syntax error: end of file unexpected (expecting "then")
So as there are only 33 lines in the script, would the line 34 be hidden or something with the word "then"
Update: I copied and pasted the 33 lines into a new file and named it instal.sh, then ran it. Result:no errors apart from this one during the install process:
ImportError: No module named RPi.GPIO ./instal.sh: line 15: [: =: unary operator expected
A
Ahem A Rivet's Shot
That sounds like an unterminated if/while/ construct in the file or similar. Unexpected end of file is always on the line *after* the last line of the file because it reads the final newline as part of the final line and then goes to read the next line to finish whatever unfinished construct is in progress and reports an error on the line after the last one.
Steve O'Hara-Smith | Directable Mirror Arrays
C:\>WIN | A better way to focus the sun
The computer obeys and wins. | licences available see
You lose and Bill collects. | http://www.sohara.org/
M
Martin Gregorie
NO! as I said, its asking for you to press any key. Read its manpage
$ man read
shows you the bash manual search down for the 'read' builtin command. This will tell you that:
- 'read' defaults to reading from stdin, which is connected to the terminal when you run it from the terminal)
- that the -n option says how many characters it should read (so -n1 will read one character)
- that the -s option tells it not to echo its input
In other words, you saw 'read' doing exactly what you asked: to wait for one keystroke and silently exit when you hit a key.
Try running this script:
===========demo script starts on the next line =================== #! /bin/bash # echo "Hit any key to continue" read -n1 -s echo "Continuing..." ===========demo script ends on the previous line ===================
save these 5 lines as a file called 'demo', make it executable ('chmod u+x demo') and run it. Now it may be clearer that 'read' is not your problem.
You should also get used to using the 'man' and 'apropos' commands. 'man' describes how to use every command (and every function in the C standard library....) and 'apropos' searches for commands, functions, etc that match your search term, so the command 'apropos file' lists all the commands that work with files.
Martin | martin at
Gregorie | gregorie dot org
D
Dennis Lee Bieber
On Wed, 30 Sep 2020 18:35:24 +0100, RobH declaimed the following:
So it is seeing an incomplete IF construct...
Now, how about running a DIFF on the two, and showing the result.
diff instal.sh install.sh
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
R
RobH
I have installed RPi.GPIO by: pip install RPi.GPIO and ran the install script again, but get this:
Traceback (most recent call last): File "", line 1, in File "/home/rob/.local/lib/python2.7/site-packages/RPi/GPIO/__init__.py", line 23, in from RPi._GPIO import * RuntimeError: This module can only be run on a Raspberry Pi! ./instal.sh: line 15: [: =: unary operator expected I2C Pins detected as 1 I2C Library setup for this revision of Raspberry Pi, if you change revision a modification will be required to i2c_lib.py Now overwriting modules & blacklist. This will enable i2c Pins Should be now all finished. Please press any key to now reboot. After rebooting run 'sudo python demo_lcd.py' from this directory
I am trying to get this to work or run on a Pi Zero with a 16x2 lcd screen, and although the python demo_lcd.py script runs but for some reason it isn't activating the lcd screen