linuxbashshellsunos

How to solve bash error "syntax error at line 3: 'CYBER_UNAME=$' unexpected"?


This error happens when I run a software containing bash script with beggining like this:

#! /bin/sh 

CYBER_UNAME=$(uname)
CYBER_UNAME_M=$(uname -m)

I tried to execute these two commands in terminal and it works fine. This error only happens when I run the shell script. What should I do?

The result of 'uname' is SunOS. This shell script cannot be modified since it's protected on our server.


Solution

  • The line

    #! /bin/sh
    

    should read:

    #!/bin/bash
    

    So, that script will probably never really work.

    If you cannot modify the script in situ, you might want to copy it to your local directory and correct it.

    Otherwise,

    tail +2 scriptname|/bin/bash 
    

    might work.