- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: KSH to CSH conversion not working.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2011 01:44 AM
тАО02-22-2011 01:44 AM
the converted script is as below.
#!/usr/bin/csh
set +u
# Generic Start and stop for HP cluster Oracle DB's
# Parameters are $1 function ... $2 DB Name
#
# First validate user is oratst
clear
set ck_user=`id | tr '(' " " | tr ')' " " | awk '{print $2}'`
if ($ck_user != 'oratst' ) then
echo 'ONLY user oratst can run this function ... '$ck_user
echo '____________________________________'
echo '\nFirst login as oratst then try again '
sleep 2
#endif
#end
# Start or Stop function
case $1 in
start) set DBFUNCTION='startup'
set LSNFUNCTION='start';;
stop) set DBFUNCTION='shutdown immediate'
set LSNFUNCTION='stop';;
*) echo 'Usage is .......... start or stop DB Name '
exit;;
esac
#Define DB and listener
case $2 in
TST) set DBNAME='TST';set DB_LISTENER='TST';;
#smst) DBNAME='smst';DB_LISTENER='smst';;
#medp_dba) DBNAME='medp';DB_LISTENER='medp_dba';;
*) echo 'only IALCH Databases smsm allowed'
exit;;
esac
ORACLE_SID=$DBNAME; export ORACLE_SID
echo 'Starting Listener now '
/oracle/TST/102_64/bin/lsnrctl $LSNFUNCTION listener_${DB_LISTENER}
sqlplus -s /nolog <
$DBFUNCTION
EOF
# End of script
However i keep getting the error ./start_stop_SAPoraDB.sh[9]: Syntax error at line 9 : `if' is not matched.
so i made a simpler script.
#!/bin/csh
if ($#argv == 0) then
echo "Proc arg missing"
endif
and i get the error ./test2[2]: Syntax error at line 2 : `if' is not matched.
why is this happening?
I have type csh and also su to the csh user with the same results.
Solved! Go to Solution.
- Tags:
- csh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2011 02:05 AM
тАО02-22-2011 02:05 AM
Re: KSH to CSH conversion not working.
I'm seeing that your "if ($ck_user != 'oratst' )" sentence has no corresponding endif, in your case is comment.
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2011 03:04 AM
тАО02-22-2011 03:04 AM
Re: KSH to CSH conversion not working.
But same is happening with second script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2011 05:39 AM
тАО02-22-2011 05:39 AM
Re: KSH to CSH conversion not working.
You need to look at the Korn/Posix syntax. A quick resource is this:
http://docs.hp.com/en/B2355-90046/index.html
Here is a more formatted, Korn or Posix script:
#!/usr/bin/sh
set +u
# Generic Start and stop for HP cluster Oracle DB's
# Parameters are $1 function ... $2 DB Name
#
# First validate user is oratst
clear
ck_user=$(id | tr '(' " " | tr ')' " " | awk '{print $2}')
if [ "$ck_user" != 'oratst' ]; then
echo "ONLY user oratst can run this function ... $ck_user"
echo "____________________________________"
echo "\nFirst login as oratst then try again "
sleep 2
fi
#
# Start or Stop function
case $1 in
start) DBFUNCTION='startup'
LSNFUNCTION='start'
;;
stop ) DBFUNCTION='shutdown immediate'
LSNFUNCTION='stop'
;;
* ) echo 'Usage is .......... start or stop DB Name '
exit
;;
esac
#Define DB and listener
case $2 in
TST ) DBNAME='TST'
DB_LISTENER='TST'
;;
# smst ) DBNAME='smst'
# DB_LISTENER='smst'
# ;;
# medp_dba)
# DBNAME='medp'
# DB_LISTENER='medp_dba'
# ;;
* ) echo 'only IALCH Databases smsm allowed'
exit
;;
esac
export ORACLE_SID=$DBNAME
echo 'Starting Listener now '
/oracle/TST/102_64/bin/lsnrctl $LSNFUNCTION listener_${DB_LISTENER}
sqlplus -s /nolog <
$DBFUNCTION
EOF
# End of script
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2011 05:44 AM
тАО02-22-2011 05:44 AM
SolutionWell that was stupid, on my part :-( You are trying to convert a working 'ksh' script to 'csh' not the other way around!
First, why do you want to do this? No matter what your default shell is, you can run scripts in any language.
Second, you are trading a fairly robust shell ('ksh') for a broken, dysfunctional one in the form of 'csh'. The C-shell is fine for very simple scripts and that's about all. I urge you to read:
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2011 05:48 AM
тАО02-22-2011 05:48 AM
Re: KSH to CSH conversion not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2011 05:51 AM
тАО02-22-2011 05:51 AM
Re: KSH to CSH conversion not working.
I usermod the sap user to ksh and my original script runs like a charm.
Found a posting on the web that ksh is prefered to csh so sap consultant now has to explain.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2011 11:08 AM
тАО02-22-2011 11:08 AM
Re: KSH to CSH conversion not working.
As JRF said, you don't have to convert the user, just individual scripts.
The #! line determines the shell as long as it is executable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2011 12:21 AM
тАО02-23-2011 12:21 AM
Re: KSH to CSH conversion not working.
That said, this is a recommendation for the _login_ shell, not for what shell you write scripts in. As others have already indicated, you can still have csh as the login shell and then write scripts in ksh/sh as long as you have the appropriate #! entry on the first line of the script.
HTH
Duncan
I am an HPE Employee