Tuesday, January 24, 2012

Some Common Unix editor errors

Problem:

1. The script test.sh was zipped copied from one linux server to another and then unzipped
2. The script test.sh wwas given right permissions
3. Scripts were read and modified using vim editor on both servers
4. Both the servers ( to and from ) have the same version of linux and red-hat
>>dmesg
dmesg command gives system details and showed that linux versions were same

While test.sh execution , below error occured

Error
/bin/sh^M: bad interpreter: No such file or directory

Cause of Error: Still not sure how ^M char could be found.
However using dos2unix test.sh solved the problem
for all the scripts use >> dos2unix *.sh ( but 'dos2unix *' does not work ?? weird !! )
b.) another solution is open using vi and then :set fileformat=unix also solved the problem

Links:
http://pbxinaflash.com/forum/showthread.php?t=3738

http://www.gizmola.com/blog/archives/87-Linux-shell-scripting-bad-interpreter-No-such-file-or-directory.html

http://www.edaboard.com/thread219178.html

2 comments:

  1. to get system related info like linux version or linux provider
    >> dmesg

    to get system RAM
    >> dmesg | grep RAM

    ReplyDelete
    Replies
    1. Memory distribution usage
      >>df -k

      Total memory of a file of folder
      >>du -hs $filename

      Delete