• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unexpected end of file when I execute my shell script

 
Ranch Hand
Posts: 85
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
reply
    Bookmark Topic Watch Topic
  • New Topic