SUMMARY: scripts not running: ^M
asaenz at Found-Tech.com
Wed Aug 3 11:45:09 EDT 2005
I got many responses I guess you guys know about this. :)
I just pasted a couple responses due to the amount I received.
The solution is to use dos2unix.
The script should run just by removing the ^M from the #!/bin/SHELLNAME^M
(from Brad_Morrison at capgroup.com)
The extra "^M" is the CR part of CR+LF that MS-DOS, Windows and friends use.
UNIX systems use only LF at end-of-line.
It "shouldn't" cause a problem with scripts. The "command not found" error
you're seeing is probably from the "sh-bang" line at the top of your scripts.
Do the scripts have something like
as line one? My guess is that the shell you're using at login doesn't like to
at the top of a script.
You can use dos2unix to remove the ^M characters. The only case I can think of
that would cause "command not found" to rear its ugly head is the sh-bang
(From Alan alan.epps at acnielsen.com)
This is common, even if you are building files within a "Unix'ed"
environment like Cygwin. I have gotten into the habit of doing a
"dos2unix" on every file I create or modify in the Windows world that I
know will need to run in the *nix worlds. If you are unfamiliar with
dos2unix, it changes all the carriage returns to line feeds, and strips
out any buried Windows-based control characters.
There is a companion program called "unix2dos" that does the opposite in
case you need to move files back the other way.
Hope this helps,
Thank you everyone for your responses.
From: Pete Clarke [mailto:pete at devilincarnate.eclipse.co.uk]
Sent: Wednesday, August 03, 2005 11:36 AM
To: Al Saenz
Cc: sunmanagers at sunmanagers.org
Subject: Re: scripts not running: ^M
> Hello Sun managers.
> I just wanted to let you know and ask if you had seen this:
> I edited some scripts using VIM on a Windows client.
> I then tried to run the scripts and would get the following
> "Command not found"
> I searched google and many folks were talking about checking permissions
> The error for permissions isn't "Command not found" so that wasn't it.
> I vi my script in Solaris and noticed ^M at the end of all the lines.
> I removed them and the script ran.
That's Windows line endings for you!
Using dos2unix to convert files with Windows line endings is one of the
easiest methods (or you could use tr .. pipe the file through "tr -d
sunmanagers mailing list
sunmanagers at sunmanagers.org
More information about the summaries