Why doesn't this simple bash script work?

The following bash script on an EMC version of redhad linux

#!/bin/bash
#
get_fs_list ()
{
sleep 3;
}
#
get_fs_list

gets

bash -v test.sh
#!/bin/bash
#
get_fs_list ()
'est.sh: line 3: syntax error near unexpected token `
'est.sh: line 3: `get_fs_list ()

What's wrong??

Thanks!
pzxkysAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pzxkysAuthor Commented:
By the way: This works fine on Solaris 10.
0
tjilpCommented:
#!/bin/bash
#
function get_fs_list ()
{
   sleep 3
}


that's it, also....use indention
0
omarfaridCommented:
I think the problem is in the space before ()

try

#!/bin/bash
#
get_fs_list()
{
sleep 3
}
#
get_fs_list
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

pzxkysAuthor Commented:
Nope. With or without space after function name  and with or without indenting ... we get the same error. Interesting isn't it. :-)
0
omarfaridCommented:
I have this working:

[omar@fedora8 ~]$ cat 2
#!/bin/bash
hi()
{
 echo hiiii
}

hi
[omar@fedora8 ~]$ ./2
hiiii
[omar@fedora8 ~]$
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
omarfaridCommented:
the script also worked and went to sleep 3 sec


#!/bin/bash
#
get_fs_list()
{
sleep 3
}
#
get_fs_list
0
pzxkysAuthor Commented:
Okay. I put your test in a new file called hi.bash and it worked fine. I then took that same stuff and put it into my test.bash file that had the original test script in it. Got that same error. Very strange. Asumption is that there is some buried special character in the file that I can't see. I then copied the original stuff at the start of this thread into a new file and it ran fine, too.

Some buried special character in that file caused this problem.
0
pzxkysAuthor Commented:
Thanks for the assistance! It was the HI script that helped me solve the problem. Some garbage embedded character in the original file. I appreciate your quick response!!!
0
omarfaridCommented:
it could be that your script contains white space in the file. Have you created the script using vi or created it with some other editor on a say windows and the transferred it to your system?
0
omarfaridCommented:
welcome
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.