HenrikBengtsson / speedtest-cli-extras

:signal_strength: Tools to enhance the speedtest-cli network tools
120 stars 32 forks source link

Error on line 38 #14

Closed manchej closed 8 years ago

manchej commented 8 years ago

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

andrew-stclair commented 8 years ago

Make sure you have Python installed

Try renaming the script speedtest-csv.py

If that doesn't work try this

python speedtest-csv.py

andrew-stclair commented 8 years ago

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

HenrikBengtsson commented 8 years ago

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

andrew-stclair commented 8 years ago

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

manchej commented 8 years ago

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

HenrikBengtsson commented 8 years ago

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?

HenrikBengtsson commented 8 years ago

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.