HenrikBengtsson/speedtest-cli-extras

Error on line 38

Closed this issue · 7 comments

Hi I have copied your code onto my pi and when I run the SH script I get the following:
speedtest-csv.sh: 38: speedtest-csv.sh: Syntax error: "(" unexpected

Make sure you have Python installed

Try renaming the script speedtest-csv.py

If that doesn't work try this

python speedtest-csv.py

The error occurs on the very first line of Python so I assume the issue is your os isn't detecting its Python instead of shell script

Note that speedtest-csv is a bash script which calls speedtest-cli that is a Python script.

Oh my bad then. I don't know what's happening there then

I fixed the issue, the function syntax is wrong for the shell script to run - don't need to have the word function - I remove the word function for each of the functions and then the code worked. I'm new to grit hub so I'm not sure how we update the code on the site - but it needs to be changed - at least for me it did to run on my pi

Could it be that you are running this in a sh shell and not in a bash shell? Or maybe in some other type of shell?

Yeah, I'm pretty sure you tried to run speedtest-csv in a sh shell, e.g.

sh bin/speedtest-csv
bin/speedtest-csv: 38: bin/speedtest-csv: Syntax error: "(" unexpected

Note that speedtest-csv is a Bash script and requires the bash shell.

I'd be surprised things work correctly when you drop the "function" keyword from the script; there are other things that are specific to Bash as well.

I recommend that you install bash and run it using bash bin/speedtest-csv.