Sep 20 2009

Bash Shell Script Error. “bad interpreter: No such file or directory error”

Today I created a simple shell script and I was getting a few odd errors:


cody@taylor:/var/some_folder/server$ ./process_xml.sh
-bash: ./process_xml.sh: /bin/sh^M: bad interpreter: No such file or directory

I figured it was probably a permissions error or an issue with the shebang (#!/bin/sh) line. I tried removing the shebang line, changing it to use dash or bash explicitly, chmoding to 777 and still no luck and another odd error.


cody@taylor:/var/some_folder/server$ sh process_xml.sh
: not found.sh: 4:

I then checked the log file that the commands were supposed to be writing to and it was filled with ‘^M’ on every line break and the log name itself was followed by a ‘?’. Took a minute or two but I finally clued in that I wrote that script on a windows machine and then exported it to an ubuntu linux server via subversion. It was just a basic text format issue.

Under DOS (Windows/PC) the end of a line of text is signalled using the ASCII code sequence CarriageReturn,LineFeed. Alternately written as CR,LF or the bytes 0x0D,0x0A. On the Macintosh platform, only the CR character is used. Under UNIX, the opposite is true and only the LF character is used.

After a quick :


cody@taylor:/var/some_folder/server$ apt-get install tofrodos
cody@taylor:/var/some_folder/server$ dos2unix process_xml.sh

Everything worked fine.

Share

Apr 19 2009

Create IPA from .app folder for the Iphone/Ipod touch to install through itunes.

An .ipa file can be opened by itunes and used to sync your iphone or ipod touch easily. The benifits of adding applications this way is to click once and have the application installed. Unlike making an iphone tunnel and using SCP to transfer the files over to the iphone or ipod touch.

I found this laying around the web and thought that it will probably useful in the future.
To build an .ipa file from a .app folder you will need to create a folder called Payload and place the .app folder inside of that.
Zip up the Payload folder, then rename the file with a .ipa extension. You can use any name you like so long as the extension is .ipa.

If you want the applications artwork to appear in iTunes (instead of a generic icon), you need to place a file called iTunesArtwork (with no extension) into the zip file on the same level as the Payload folder (not in it). This is actually a jpeg file of a 512×512 image and this will appear in iTunes for the app.

I haven’t had a chance to try this yet due to mostly developing web apps so far (No Mac OS Here) but I’ve seen many posts that it works. So any feedback would be great. Of course you need a jailbroken iphone or ipod touch for this to work along with having downloaded at least one legit free application from the apple app store.

Share