LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-29-2010, 04:03 PM   #1
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Rep: Reputation: 15
Start Script


I have start up script as below:

Getting following error

./WebPortalUptest2.sh: line 20: portal_start: command not found
>>> host name is --> dev2 and portal_start is -->

-------------------------------------------------------
11/29/10 13:47:55 prtldev2 >>> Start Portal <<<

Script:

{/}
host=$(hostname);
dt=$(date +'%D %T')
logfile='PortalUp.log'
profile_path='/opt/IBM/WebSphere/wp_profile'
#
#--> Determine which portal to use based on host name <--
#--> set portal 1for host name prd5, stg5, <--
# wprd5, tst5, <--
# wstg5 or dev2 <--
#
#--> set portal2 for host nameprd6, stg6, <--
# wprd6, or tst6 <--
#
portno='null';
#
if [ "$host" == "prd5" ] || [ "$host" == "stg5" ] ||
[ "$host" == "wprd5" ] || [ "$host" == "tst5" ] ||
[ "$host" == "wstg5" ] || [ "$host" == "dev2" ];
then
portal_start ='$profile_path/bin/startServer.sh WebSphere_Portal'
else
if [ "$host" == "prtlprd6" ] || [ "$host" == "stg6" ] ||
[ "$host" == "wprd6" ] || [ "$host" == "tst6" ];
then
portal_start='$profile_path/bin/startServer.sh WebSphere_Portal_2'
else
portal_start='dummy'
echo ">>> wrong host <<<" $host
echo ">>> wrong host <<<" $host
echo ">>> wrong host <<<" $host
fi
fi
#
echo ">>> host name is -->" $host " and portal_start is -->" $portal_start
#

echo " ";
echo "-------------------------------------------------------";
dt=$(date +'%D %T')
echo $dt $host ">>> Start Portal <<<";
echo " ";
#
#
#dt=$(date +'%D %T')
#echo $dt $host ">>> End of Priming Portal Pages <<<";
#echo " ";
{\}
 
Old 11-29-2010, 04:53 PM   #2
BertM
LQ Newbie
 
Registered: Jan 2010
Location: Belgium
Distribution: Debian
Posts: 17

Rep: Reputation: 0
I assume that this is line 20:

portal_start ='$profile_path/bin/startServer.sh WebSphere_Portal'

The problem lies in the space before the equals-sign; try removing it so it reads:

portal_start='$profile_path/bin/startServer.sh WebSphere_Portal'

Last edited by BertM; 11-29-2010 at 04:55 PM.
 
Old 11-29-2010, 06:12 PM   #3
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
space before the equals-sign

I removed the space as below:

portal_start='$profile_path/bin/startServer.sh WebSphere_Portal'


I did not get error this time but it did not start portal too.

Here is the output


>>> host name is --> dev2 and portal_start is --> $profile_path/bin/startServer.sh WebSphere_Portal

-------------------------------------------------------
11/29/10 16:07:55 dev2 >>> Start Portal <<<
 
Old 11-29-2010, 06:52 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Could you try executing a small rewrite and post in BB code or attach plain text complete output of running:
Code:
#!/bin/sh -vxe
HOST=$(hostname -s)
DATESTAMP=$(date +'%D %T')
STARTSCRIPT="/opt/IBM/WebSphere/wp_profile/bin/startServer.sh"

if [ -x "${STARTSCRIPT}" ]; then
 echo "${STARTSCRIPT} not executable, exiting."
 exit 1
fi

case ${HOST} in
 prd5|stg5|wprd5|tst5|wstg5|dev2)
  STARTCMD="${STARTSCRIPT} WebSphere_Portal"
 ;;
 prtlprd6|stg6|wprd6|tst6)
  STARTCMD="${STARTSCRIPT} WebSphere_Portal_2"
 ;;
 *)
  unset STARTCMD
  echo "Unlisted host ${HOST}."
  exit 1
 ;;
esac

if [ ${#STARTCMD} -ne 0 ]; then
 echo "${dt} host: ${HOST} start command: ${STARTCMD}"
 /bin/sh -vxe $STARTCMD &
 disown %1
 # or: echo "${STARTCMD}"|/usr/bin/at now
 # or: exec ${STARTCMD}
fi

exit 0
 
Old 11-30-2010, 04:55 AM   #5
BertM
LQ Newbie
 
Registered: Jan 2010
Location: Belgium
Distribution: Debian
Posts: 17

Rep: Reputation: 0
Your script seems to be correct, but it's not really executing anything in the end!

Look at this code block:
Code:
if [ "$host" == "prd5" ] || [ "$host" == "stg5" ] ||
[ "$host" == "wprd5" ] || [ "$host" == "tst5" ] ||
[ "$host" == "wstg5" ] || [ "$host" == "dev2" ];
then
portal_start ='$profile_path/bin/startServer.sh WebSphere_Portal'
This line puts the path in the variable $portal_start

Then later in the script, you have this:
Code:
echo ">>> host name is -->" $host " and portal_start is -->" $portal_start
#

echo " ";
echo "-------------------------------------------------------";
dt=$(date +'%D %T')
echo $dt $host ">>> Start Portal <<<";
echo " ";
If you look at it carefully, you'll see you only have a few echo-commands.
Nothing is being executed; it just prints some text.
Try adding ths after the previous block of code:
Code:
$portal_start
This should try to execute the contents of the $portal_start variable, which contains the path to your WebSphere binary.
If the path, specified at the beginning of the script, is correct, it should start your server.
 
Old 11-30-2010, 09:28 AM   #6
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
Do I need to add $portal_start as below?

$portal_start ='$profile_path/bin/startServer.sh WebSphere_Portal'

OR

after

portal_start ='$profile_path/bin/startServer.sh WebSphere_Portal'

$portal_start
 
Old 12-01-2010, 05:58 AM   #7
BertM
LQ Newbie
 
Registered: Jan 2010
Location: Belgium
Distribution: Debian
Posts: 17

Rep: Reputation: 0
I copied your script and added it in bold, it's at the bottom of the script.
I also corrected your earlier mistake with the space.

Try it and if it still doesn't work, post the output or error messages you may receive.

Code:
host=$(hostname);
dt=$(date +'%D %T')
logfile='PortalUp.log'
profile_path='/opt/IBM/WebSphere/wp_profile'
#
#--> Determine which portal to use based on host name <--
#--> set portal 1for host name prd5, stg5, <--
# wprd5, tst5, <--
# wstg5 or dev2 <--
#
#--> set portal2 for host nameprd6, stg6, <--
# wprd6, or tst6 <--
#
portno='null';
#
if [ "$host" == "prd5" ] || [ "$host" == "stg5" ] ||
[ "$host" == "wprd5" ] || [ "$host" == "tst5" ] ||
[ "$host" == "wstg5" ] || [ "$host" == "dev2" ];
then
portal_start='$profile_path/bin/startServer.sh WebSphere_Portal'
else
if [ "$host" == "prtlprd6" ] || [ "$host" == "stg6" ] ||
[ "$host" == "wprd6" ] || [ "$host" == "tst6" ];
then
portal_start='$profile_path/bin/startServer.sh WebSphere_Portal_2'
else
portal_start='dummy'
echo ">>> wrong host <<<" $host
echo ">>> wrong host <<<" $host
echo ">>> wrong host <<<" $host
fi
fi
#
echo ">>> host name is -->" $host " and portal_start is -->" $portal_start
#

echo " ";
echo "-------------------------------------------------------";
dt=$(date +'%D %T')
echo $dt $host ">>> Start Portal <<<";
echo " ";
$portal_start
#
#
#dt=$(date +'%D %T')
#echo $dt $host ">>> End of Priming Portal Pages <<<";
#echo " ";
Just to make it clear:

portal_start='$profile_path/bin/startServer.sh WebSphere_Portal'
puts the link to your executable file inside the portal_start variable.

$portal_start
with the dollar-sign at the front, tries to execute the contents of the variable i.e. the executable the variable is pointing to.
 
Old 12-01-2010, 10:26 AM   #8
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
I have modified script as below and its work ok.
Only getting following message:

./WebPortaltest.sh: line 56: syntax error near unexpected token `else'
./WebPortaltest.sh: line 56: `else'

This is the else before second logic

{/}
#
else
if [ "$host" == "prd6" ] || [ "$host" == "stg6" ] ||
[ "$host" == "wprd6" ] || [ "$host" == "tst6" ]; {/}


Here is the latest script:
{/}
#------------------> web_portal_start.sh <-------------------#
# #
# Modification log #
# ---------------- #
# #
# ------Please add new entries at the top. Be proud #
# | of your work. Comment it! #
# V #
# DATE WHO DESCRIPTION #
# ---- --- ----------- #
# 01/12/10 tst initial release to start portal #
# #
#-------------------------------------------------------------#
#!/bin/bash
set -x
host=$(hostname);
dt=$(date +'%D %T')
logfile='PortalUp.log'
profile_path='/opt/IBM/WebSphere/wp_profile'
#
#--> Determine which portal to use based on host name <--
#--> set portal1 for host name prd5, stg5, <--
# wprd5, tst5, <--
# wstg5 or dev2 <--
#
#--> set portal2 for host name prd6, stg6, <--
# wprd6, or tst6 <--
#
#portal_start='null';
#
if [ "$host" == "prd5" ] || [ "$host" == "stg5" ] ||
[ "$host" == "wprd5" ] || [ "$host" == "tst5" ] ||
[ "$host" == "wstg5" ] || [ "$host" == "dev2" ];
then
su -l admin -c /home/admin/scripts_PS/startportal & >> /tmp/weblog/$logfile
echo $dt start command for $server_name on $host Server has been issued. >> /tmp/weblog/$logfile
fi
# check every 3 minutes to see if server has been started. if server does not start in 30 minutes (10 checks), exit the script with
# return code 8
let "count = 0"
while [ $count -lt 11 ]
do
let "count = count +1"
#
dt=$(date +'%D %T')
#
if [ -f $profile_path/logs/$server_name/$server_name.pid ]; then
echo $dt $server_name on $host server has been successfully started. >> /tmp/weblog/$logfile
exit
#
else
echo $dt start process for $server_name on $host server is still running. checked $count times, 3 minutes apart >> /tmp/weblog/$logfile
sleep 180
fi
#
else
if [ "$host" == "prd6" ] || [ "$host" == "stg6" ] ||
[ "$host" == "wprd6" ] || [ "$host" == "tst6" ];
then
su -l admin -c /home/admin/scripts_PS/startportal_2 & >> /tmp/weblog/$logfile
echo $dt start command for $server_name on $host Server has been issued. >> /tmp/weblog/$logfile
fi
# check every 3 minutes to see if server has been started. if server does not start in 30 minutes (10 checks), exit the script with
# return code 8
let "count = 0"
while [ $count -lt 11 ]
do
let "count = count +1"
#
dt=$(date +'%D %T')
#
if [ -f $profile_path/logs/$server_name/$server_name.pid ]; then
echo $dt $server_name on $host server has been successfully started. >> /tmp/weblog/$logfile
exit
#
else
echo $dt start process for $server_name on $host server is still running. checked $count times, 3 minutes apart >> /tmp/weblog/$logfile
sleep 180
fi
done
#
dt=$(date +'%D %T')
echo $dt start process for $server_name on $host server DID NOT complete successfully. checked $count times, 3 minutes apart >> /tmp/weblog/$logfile
exit 8
#
{\}


Thanks

Last edited by dnaqvi; 12-01-2010 at 10:29 AM.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
start script bash when system start,stop,reeboot, how ?? melmar Linux - General 4 12-10-2009 06:58 AM
Start-up script to start wlan interface Bluefightingcat Linux - Networking 7 08-30-2009 04:09 PM
ssh - using variables in call to start remote script from local script babag Linux - Networking 2 06-03-2008 04:50 PM
Start a script after GDM autologin, don't quit when script finishes Plastech Linux - Newbie 2 05-29-2007 10:15 AM
How to start a Tcl/Tk script by simply invoking the script file itself ? cyu021 Programming 2 10-10-2004 11:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:08 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
Open Source Consulting | Domain Registration