I already entered into this Bash / Shell material and got some network analysis for uni assignment.
Just trying to make a simple loop, but getting a weird error that could not be fixed despite a 2 hour google scan:
#!/bin/bash x=1 while [ $x -le 5 ] do echo "Welcome $x times" x=$(( $x + 1 )) done
I tried using a for loop using the following syntax:
#!/bin/bash for i in {1..5} do echo "Welcome $i times" done
Whenever I put the first script on my server, I get the following message:
./temp.sh: line 8: syntax error: unexpected end of file
Before running this file, I ran the following commands to add permissions and make an executable:
ls -l temp.sh chmod +x temp.sh
As a note, I found the following loop stack stack question, copied the โfixed codeโ and got the same error: Looping a Bash Shell Script
Im running version 4+ and using G-VIM as a text editor in Windows 7. Has anyone got any ideas?
MANAGED BY THE DECISION OF THIS MYSELF:
Seeing that my reputation is still too low, I canโt answer this question right now to stop people wasting time on how I fixed it:
Well, I managed to fix it, so he will leave it for everyone who is looking around.
My problem was that I used FileZilla to connect to my server. It seems that although I used WinVi or G-Vim to create the files, FileZilla added some extra characters to the end of my file when I transferred it to the server when I started Windows.
I switched to WinSCP as my communication agent and tried it, and it worked fine fine.
Thanks for the other answers.
Lewis