• Post Reply Bookmark Topic Watch Topic
  • New Topic

unexpected end of file when I execute my shell script  RSS feed

 
Ranch Hand
Posts: 85
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 3 shell scripts

script1.sh



script2.sh



script3.sh



My lead wants me to combine all these 3 scripts into one, since there is no point in having 3 separate scripts here. These 3 scripts works fine separately, but I first tried to combine first 2 scripts and I am getitng unexpecetd end of file error when I execute this script:

script1+script2.sh



I am running the above scripts using the following script:



Please help me resolve this error.
 
author & internet detective
Marshal
Posts: 37518
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you by any chance FTP the files to edit them? IF so, you might have messed up the line ending encoding. FTP them again in ASCII mode to fix this.
 
swathi bairu
Ranch Hand
Posts: 85
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Did you by any chance FTP the files to edit them? IF so, you might have messed up the line ending encoding. FTP them again in ASCII mode to fix this.


I edited them using vim command. Don't understand what do you mean by FTP in ASCII mode though.
 
swathi bairu
Ranch Hand
Posts: 85
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
swathi bairu wrote:I have 3 shell scripts

script1.sh



script2.sh



script3.sh



My lead wants me to combine all these 3 scripts into one, since there is no point in having 3 separate scripts here. These 3 scripts works fine separately, but I first tried to combine first 2 scripts and I am getitng unexpecetd end of file error when I execute this script:

script1+script2.sh



I am running the above scripts using the following script:



Please help me resolve this error.


I am not sure what exactly worked, but I deleted and retyped using vim command. And the new file is working. Here is my new file:

 
Saloon Keeper
Posts: 18800
74
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Technically, it's not "ASCII" mode for FTP - it's "TEXT" mode.

An FTP server usually transfers data in one of 2 possible modes: TEXT mode or BINARY mode. Depending on what FTP system you have, the default mode may be either one. Windows favors text mode and unix/linux favors binary mode.

The difference between the 2 modes is that in binary mode, the data is transferred byte-for-byte unchanged. What you receive is EXACTLY what was on the server and likewise for sending.

In text mode, the data transfer is scanned for end-of-line characters and translated, because in Windows/DOS, lines end with CR/LF, but in Unix and Linux, a single end-of-line character (NL, also known as "LF") is considered a good enough hint. So if you download a ZIP file in text mode, you'll get a trashed file that cannot be used. But if you download a text file in binary mode, you may or may not see proper line breaks.

There theoretically could be an "ASCII" mode and an "EBCDIC" mode if your FTP client/server setup was intended to be mainframe-friendly, but I don't think that anyone ever did that. For one thing, end-of-line characters aren't a natural feature of mainframe files (they tend to favor physical records), and for the rest, mainframe people are supposed to know how to deal with such things (and sometimes they even do).

The usual commands for an FTP client to switch between text and binary modes are.... "text" and "binary".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!