Link to home
Start Free TrialLog in
Avatar of Tech_20
Tech_20

asked on

Unix script error

I have a unix script (validint.bash) that continues to give the following error after I type the file name and following input...

   sh-3.2# bash validint.bash 123.45

Then I get this error message...

   : command not found 3:
   'alidint.bash: line 4: syntax error near unexpected token `{
   'alidint.bash: line 4: `function validint() {

I attached the script below in a text (.rtf) file. Please help. Thanks.
unix-script.rtf
SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tech_20
Tech_20

ASKER

Both of you have great points. I made the changes woolmilkporc suggested. I also transferred the code from Sublime2 to MacVim after experiencing similar errors and it worked. I had another script "validFloat2.bash" referencing the previous script named "validint2.bash" and it worked but I also received this error message.

input
sh-3.2# bash validFloat.bash 1234.56

output
validint2.bash: line 12: [: missing `]'
validint2.bash: line 19: [: missing `]'
validFloat.bash: line 32: [: fractionalPart: unary operator expected
1234.56 is a valid floating-point value

Any other suggestions.
validint2.rtf
validFloat2.rtf
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tech_20

ASKER

Thanks. The comments on variable assignments, carriage returns and choice of code editor helped!