Script issue with "Undefined variable"
Hi!
I wrote a simple script that's get a variable by input. I can run it fine by using sh script. The problem i having is that when i try to execute it with ./script i get: lala: Undefined variable. datum=: Command not found. The script: #!/bin/csh -f # echo write something: read lala datum=`grep $lala /var/log/changelog | tail -1 | awk '{print $2 " " $3 " " $4 " " $5}'` echo Datum......: $datum I understand that sh make the script execute in a child environment or something like that. But how do i make this script executable by ./? |
Change the first line in the file to
Code:
#! /bin/sh |
Quote:
Thanks! |
You really DON'T want to use csh as a programming shell, but I know, "to each his own".
That being said, you aren't even writing the script in csh, you are using sh or bash syntax and then trying to send that to the csh interpreter. Try this instead: Code:
#!/bin/bash If you REALLY want to use csh, then you will need to convert your script to use csh syntax (note, there is no "read" command in csh). HTH Forrest |
All times are GMT -5. The time now is 03:04 PM. |