Bash Script return an error ‘: not a valid identifierd: `

When we write  a Linux Shell script on windows Text Editor such like a  Notepad, and port it into a Linux Machine . This Shell Script show the following Error  ‘: not a valid identifierd: ` 

For example we write a shell script “employee.sh “

[root@localhost ~]# chmod +x employee.sh
[root@localhost ~]# ./employee.sh
Please enter the TABLENAME :EMPLOYEE
‘: not a valid identifierad: `TABLENAME


Because Linux and Window use the different end of line character So Windows add an additional Carriage-Return character to every Newline. Now we rewrite same Script on Linux machine in the vi editor.

[root@localhost ~]# vi emp.sh
[root@localhost ~]# ./emp.sh
-bash: ./emp.sh: Permission denied
[root@localhost ~]# chmod +x emp.sh
[root@localhost ~]# ./emp.sh
Please enter the TABLENAME :EMP
Please enter the EMPLOYEE STATUS :0
Please enter the EMPLOYEE ID  :300
ERROR 1049 (42000): Unknown database ’employees’
[root@localhost ~]#


So now you run your Linux Shell script successfully.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s