Problem to make scripts on a VMWARE Vitual Machine
Hi guys
I am a new UNIX environment user who's got troubles trying to make scripts on a VMWARE virtual machine. If I use "if" conditions or "for" loops on the shel using the fallowing syntax everything goes well: $ if condition > then > commands > else > commands > fi But when I put it into a script, when I try to run it, is like if the "then" and "fi" statements where not seen by the VM. And the shell shows messages such as "syntax error" or "uncorrect end of file". To get rid of these errors, I am obliged to use the following syntax: if condition; then commands; else commands; fi; or if condition; then commands else commands fi; And I don't understand because I thought I was not allowed to put a ";" after the "fi" statement. I also have troubles with arithmetics expressions. I don't understand why the expressions I found in books or on the web don't work in scripts as they do work on the shell. Does anyone know where do these problems come from? Is it me, I may be so bad using UNIX that I didn't find out things? Is it a bad configuration of VMWARE? Thank U for your help PEDROSAN:newbie: |
hi there,
did you put #!/bin/bash on the first line? this makes sure the script is executed within the bash enviroment. the ;'s are ok, that's just the way the script is seen by the enviroment. greetz, .-=~ iluvatar ~=-. |
Hi !!!
Thank U for your answer. I actually put the "#! /bin/bash" at the beginning of my script but I put a space in it. Do you think this was a mistake? I also put comments before. Do you think this could be wrong to? I am gonna try to modify this line and I will see. See U PEDROSAN |
I found out where my problem came from.
I was editing my script on Windows and running it on Linux. The Windows editor added characters without showing them. So when I tried to run it I had errors. Bye PEDROSAN |
All times are GMT -5. The time now is 07:15 PM. |