LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-12-2012, 05:19 PM   #1
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 188

Rep: Reputation: Disabled
unexpected eof again...


Hi all

I have this funny little script, its suppose to make me a tone of users. But right now I am getting an error about unexpected end of file. I am sure many of you have come across this before, and many people raising this question, god knows google certainly gave a ton of stuff to read through, but still nothing really fixed it.


Here is the code, I have removed a whole bunch of the actual user creation because I have already ruled them out. I removed those chunks, ran it again, and still got the same errors.

Code:
#******************************************************************************
#  
#  Usage: ./Add_Subscriber.sh user id  how many ids
#    e.g. ./Add_Subscriber.sh 4932782111000 10 will add 4932782111000-4932782111009
#
# Version PA1
#*****************************************************
i_loop=0
while [ $i_loop -lt $2 ]; do

i_subscriber=`expr $1 + $i_loop`

echo loop number: $i_loop
echo Writing subsriber: $i_subscriber
#removed a bunch of stuff here

i_loop=`expr $i_loop + 1`
done
any help you guys can provide I would really appreciated it.

I looked for extra CRs and etc, but still couldn't find anything.

the linux is running some kind of corporate modified suse 11.

Last edited by jzoudavy; 08-12-2012 at 05:20 PM. Reason: text editor messed up some of the formatting
 
Old 08-12-2012, 05:30 PM   #2
i_joh
Member
 
Registered: Apr 2005
Distribution: Debian
Posts: 82

Rep: Reputation: 5
Worked for me. That is up to the start number 49327821110000000000. Then number out of range.

Edit: Worked in posix mode too, run with /bin/sh

Last edited by i_joh; 08-12-2012 at 05:34 PM.
 
Old 08-12-2012, 07:03 PM   #3
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 188

Original Poster
Rep: Reputation: Disabled
how did you run it? just

./Provision_Sub_skeleton_code.sh x y, x and y being whatever number?

cause I keep getting this:

./Provision_Sub_skeleton_code.sh
./Provision_Sub_skeleton_code.sh: line 24: syntax error: unexpected end of file
 
Old 08-12-2012, 07:48 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,983

Rep: Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182
Well I would have 2 questions for you:

1. The while test requires the second of 2 parameters to be passed in yet you run it with none?

2. The code you have presented does not have 24 lines, so what are you running?
 
Old 08-12-2012, 07:54 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,309

Rep: Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744Reputation: 2744
Interesting, because I only count 18 lines in that code; are you SURE that's all of it??
Incidentally, try amending the top to
Code:
#!/bin/bash
set -xv
#******************************************************************************
#
ie enforce the shell you want to use and turn on debugging.

Also, do arithmetic using (( )); its more efficient and modern http://tldp.org/LDP/abs/html/arithexp.html

You can enforce *nix line endings with http://linux.die.net/man/1/dos2unix

HTH
 
2 members found this post helpful.
Old 08-12-2012, 08:59 PM   #6
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 188

Original Poster
Rep: Reputation: Disabled
hi grail

missing lines are comments containing private information, which i can't really post on a public forum.

hi chrism01

I tried the !/bin/bash, I still get the same error about unexpected end of file.

Actually !/bin/bash gave an error about bad interpretor and I had to change it to ./bin/bash instead.
I also had to take out set -vx because it doesn't like the way I set the options, according to man i am suppose to use --, but that just gave me the same error.

sorry if I sound a bit short, this is the 3rd time i am typing this because the token keeps expiring.

Thanks for all your help guys.
Davy
 
Old 08-12-2012, 09:09 PM   #7
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 188

Original Poster
Rep: Reputation: Disabled
Hi guys

here is something interesting, i was reading the shell guide on tlpd and figured i would try this:

Proc_m1_s1# bash -posix Provision_Sub_skeleton_code.sh 12 1
+ i_loop=$'0\r'
Provision_Sub_skeleton_code.sh: line 26: syntax error: unexpected end of file

what is this 0\r?

Last edited by jzoudavy; 08-12-2012 at 09:14 PM. Reason: fixing input to cmd
 
Old 08-12-2012, 09:30 PM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,983

Rep: Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182
You have created the file in Windows and hence the unusual line endings are causing issues. See chrism01's link about dos2unix.

Also, the reason the bash section was causing you errors is you missed or mis-read chrism01's example and left off the leading #, the hash is required
as together with ! it tells the script which interpreter to use. I would suggest that without this being set correctly would be the reason why 'set' was
misbehaving for you.
 
Old 08-12-2012, 09:33 PM   #9
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 188

Original Poster
Rep: Reputation: Disabled
hi grail

the hash isn't the issue, both . and ! had the has in front of them.

I will try the dos2unix and get back to.
 
Old 08-12-2012, 09:40 PM   #10
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 188

Original Poster
Rep: Reputation: Disabled
hi grail

You might be onto something, cause i do use windows notepad++ and then upload it to the linux environment where it is run.

here is the output from dos2unix.exe, i have to run it on my PC's cygwin because the linux environment doesn't have it.

correction: i was using the wrong options, you have to use -n if you are writing to a new file.

so here goes nothing

Last edited by jzoudavy; 08-12-2012 at 09:42 PM. Reason: corrections
 
Old 08-12-2012, 09:46 PM   #11
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 188

Original Poster
Rep: Reputation: Disabled
AND WE HAVE A WINNER!!!

i used the dos2unix and now the code works! this is awesome. If it fails i would have to create 1000 users by hand.

thanks a lot for your help guys

Davy
 
Old 08-12-2012, 10:07 PM   #12
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 188

Original Poster
Rep: Reputation: Disabled
hey, do i have to this everytime I use notepad++?

I mean, I use dos2unix to generate the new file, and use notepad++ to edit the new file, do I still have to dos2unix it afterwards?
 
Old 08-12-2012, 11:37 PM   #13
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,983

Rep: Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182Reputation: 3182
Depends on whether notepad++ overwrites any changes when you save and puts the windows line endings back in?

Simple test would be to change file you have run dos2unix on in notepad++ and then use cat -A in linux and see what the output is.
To check it is correct create a simple file on linux (echo word > test_file) and use the same cat -A
 
Old 08-13-2012, 02:26 PM   #14
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
notepad++ appears to have the ability to handle and convert line endings itself.

http://npp-community.tuxfamily.org/d...newline-format
 
Old 08-13-2012, 03:47 PM   #15
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 188

Original Poster
Rep: Reputation: Disabled
hi all

so i tried it, as in the modify with dos2unix and then use the notepad++ to edit it again.

I found that you do not have to run dos2unix again on the file.

But if its a brand new file, you might have to run the dos2unix.

Thanks for all your help guys.

Davy
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unexpected EOF in archive Drone1 Linux - Newbie 5 11-09-2006 05:31 AM
[crontab] unexpected EOF G00fy Programming 7 11-01-2006 03:09 AM
G4U unexpected EOF jonax2k5 Linux - Software 1 11-16-2005 11:05 AM
Unexpected EOF Error??? ITJedi Programming 2 07-09-2003 02:01 PM
tar: Unexpected EOF saavik Linux - Newbie 1 04-13-2002 02:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration