3

We are trying to generate a bash shell script for use on a Linux system from values stored in a Google spreadsheet and we are having difficulties.

I can create the script contents fine and save the resultant file to Google drive but the problems come about when I try to use the file on a Linux box. When the file is downloaded as plain text the encoding is set to UTF-8 which Linux thinks is a binary file when I try to execute it. The other problem we are having is the line endings are forcibly set to the host PC which is a windows box so I get CRLF not LF as required by the Linux machine. I was wondering if there was anyway in Google app scripting to forcibly give me ASCII encoding and UNIX line ending somehow. I'd rather not have to pipe the file contents through strings and dos2unix before being able to use it.

apaul
  • 16,092
  • 8
  • 47
  • 82
  • 1
    not quite sure... but [this answer](http://stackoverflow.com/questions/13781074/sending-iso-8859-1-chars-from-google-apps-script) might help you?? – tzelleke Jul 03 '13 at 09:58
  • Thanks for posting that link very helpful, I finally solved the problem by using the DriveApp rather than the DocumentApp object to create the shell script document on google drive, this coupled with the getDataAsString() method has solved the issue completely. – Technomancer Jul 04 '13 at 00:08
  • 4
    Why don't use add the solution to your question aka answering your own question, so that we all can benefit !!! – Jacob Jan Tuinstra Jan 08 '14 at 13:23

0 Answers0