LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 06-25-2008, 10:59 AM   #1
xipiska
LQ Newbie
 
Registered: Jun 2008
Posts: 8

Rep: Reputation: 0
script error


hello i got server quad core with linux CentOS
i want to install script (this is a part of the script)

PHP Code:
#!/bin/bash

IPconfig=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | cut -d\  -f1`;
IPon="$IPconfig";

id grep "uid=0(" >/dev/null
if [ $? != "0" ]; then
        uname 
-grep -i CYGWIN >/dev/null
        
if [ $? != "0" ]; then
             printf 
"You must be Root to do this!"
               
su > /dev/null
                
        fi
fi

id 
grep "uid=0(" >/dev/null
if [ $? != "0" ]; then
        uname 
-grep -i CYGWIN >/dev/null
        
if [ $? != "0" ]; then
          
echo "Wrong Root Password, Try Again!"
           
           
./Install.sh
         
exit 1
              
        fi
fi

#adduser rpanel > /dev/null 2> /dev/null

echo "Welcome To Install!"
/usr/sbin/adduser rpanel > /dev/null 2> /dev/null
printf 
"Loading Setup"
sleep 1
printf 
"."
sleep 1
printf 
"."
sleep 1
printf 
"."
echo ""
if cd RPanel 2> /dev/null
then
echo ""
cd RPanel 2> /dev/null
cd 
..
else

echo 
"Error: Missing Files, Cannot Start Install."
printf "Exiting"
sleep 1
printf 
"."
sleep 1
printf 
"."
sleep 1
printf 
"."
echo ""
exit 0
exit 1

fi


if cd vRPanel 2> /dev/null
then
cd vRPanel 2
> /dev/null

tar 
-zxvf RPanel-Files.tar.gz 
chmod 777 
*
cd ..
chmod 777 vRPanel -R
else
echo 
"Error: Missing Files, Cannot Start Install."
echo "Exiting"
sleep 1
printf 
"."
sleep 1
printf 
"."
sleep 1
printf 
"."
echo ""
exit 1

fi

if cd commands 2> /dev/null
then
cd commands 2
> /dev/null
cd 
..
else
echo 
"Error: Missing Files, Cannot Start Install."
printf "Exiting"
sleep 1
printf 
"."
sleep 1
printf 
"."
sleep 1
printf 
"."
echo ""
exit 0
exit 1

fi
printf 
"Setuping RPanel IP Config"
sleep 1
printf 
"."
sleep 1
printf 
"."
sleep 1
printf 
"."
echo ""

for ((i=1;$i<=3;i=$i+1))
{
printf "Enter Your IP (Default: $IPconfig): "
read ipcon
if [ "$ipcon!= "" ]; then
IPconfig
="$ipcon"
fi


printf 
"Is $IPconfig the IP that you chose? (yes,no): "
read yesno

if [ "$yesno"yes" ]; then

i
=10

fi

if [ "$yesno"no" ]; then

i
=1
IPconfig
="$IPon";
exit

fi

if [ "$yesno"" ]; then

i
=1
IPconfig
="$IPon";

fi


when im doing "sh Install.sh" through the ROOT
it writes me :
PHP Code:
command not found:
command not found:
command not found:
'nstall.sh: line : syntax error near unexpected token `
'
nstall.shline : `for ((i=1;i<=3;i=i+1)) 
whats the problem here?!

thanks

Last edited by xipiska; 06-25-2008 at 11:03 AM. Reason: wrong info
 
Old 06-25-2008, 12:19 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
The error message seems not complete (missing line numbers, missing which command not found), anyway I can see a syntax error in the for loop reported by the error message: a C-style for loop is permitted in bash, but you can't put the brackets to embed the code. In bash you use code inside brackets only when define a function. The C-style loop syntax is
Code:
for ((i=1; i<=N; i++))
do
  some commands here
done
 
Old 06-25-2008, 01:49 PM   #3
xipiska
LQ Newbie
 
Registered: Jun 2008
Posts: 8

Original Poster
Rep: Reputation: 0
its still not working , it is doing the same error
 
Old 06-25-2008, 02:16 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
The error you've posted is exactly what do you see in the terminal? I wonder where are the line numbers and the names of the "not found" commands.
 
Old 06-25-2008, 02:53 PM   #5
xipiska
LQ Newbie
 
Registered: Jun 2008
Posts: 8

Original Poster
Rep: Reputation: 0
no , it writes line 140 i just didnt wrote the number becouse its only the part of the script
 
Old 06-25-2008, 07:26 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Add

set -xv

as the 2nd line of code and run the prog again and show us the output.
 
Old 06-25-2008, 07:39 PM   #7
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Try:

bash Install.sh

vs.

sh Install.sh
 
Old 06-26-2008, 01:29 PM   #8
xipiska
LQ Newbie
 
Registered: Jun 2008
Posts: 8

Original Poster
Rep: Reputation: 0
[root@dasm RPSetup]# bash Install.sh
: invalid option 2: set: -
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
: command not found:
: command not found:
: command not found:
'nstall.sh: line 141: syntax error near unexpected token `
'nstall.sh: line 141: `for ((i=1; i<=N; i++))


its not helping
 
Old 06-26-2008, 01:41 PM   #9
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Did you change your bash shell to another shell, such as dash, to attempt to get a faster shell?
 
Old 06-26-2008, 02:18 PM   #10
xipiska
LQ Newbie
 
Registered: Jun 2008
Posts: 8

Original Poster
Rep: Reputation: 0
no can u tell me how to do it ? i dont have bash i think
 
Old 06-26-2008, 02:30 PM   #11
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
No, never mind. Bash is outputting that set syntax error message; so you do have bash.

I know what the error is and can reproduce it. You have used an editor that is saving files in DOS format.

Open your script with vi and change the file format. Type exactly the steps below:

Code:
vi Install.sh
:set ff=unix
:wq!
Now run your script.

Last edited by Mr. C.; 06-26-2008 at 03:46 PM.
 
Old 06-26-2008, 03:17 PM   #12
xipiska
LQ Newbie
 
Registered: Jun 2008
Posts: 8

Original Poster
Rep: Reputation: 0
hi : ive tried to do what you said and here is the result :

when i wrote :set ff unix

Quote:
fileformat=dos
E518: Unknown option: unix
Press ENTER or type command to continue
but when im doing :wq! its exiting the file
 
Old 06-26-2008, 03:44 PM   #13
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Try vim Install.sh instead of vi. Do the same thing.
 
Old 06-26-2008, 03:46 PM   #14
xipiska
LQ Newbie
 
Registered: Jun 2008
Posts: 8

Original Poster
Rep: Reputation: 0
-bash: vim: command not found
 
Old 06-26-2008, 03:46 PM   #15
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Sorry, I forgot the = sign. See the above correction, and redo.

You can also use dos2unix to convert the file from dos format to Unix format, but the above method will work too.
 
  


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
Backup Script error "line 31: syntax error: unexpected end of file" eswanepoel General 7 12-07-2007 10:28 AM
bash script read error and awk ouptut error whited Programming 4 10-16-2007 08:05 PM
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 10:10 PM
error when tying to run python script(bash error?) shanenin Programming 5 01-10-2006 11:01 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 05:21 PM


All times are GMT -5. The time now is 01:19 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration