Fi Unexpected Error In Unix
Contents |
Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here. Search Forums Show Threads Show Posts
Syntax Error Near Unexpected Token Fi' Shell Script
Tag Search Advanced Search Unanswered Threads Find All Thanked Posts Go to Page... syntax error near unexpected token fi' in unix unix and linux commands - unix shell scripting fi unexpected Shell Programming and Scripting
Syntax Error Near Unexpected Token Fi Mac
Thread Tools Search this Thread Display Modes #1 07-10-2010 svajhala Registered User Join Date: Nov 2009 Last Activity: 11 March 2016, 4:17 PM EST Posts: 114 Thanks: syntax error near unexpected token fi' cygwin 37 Thanked 0 Times in 0 Posts fi unexpected Hi gurus, I wrote the below script which finds the process ids and if there is a change b/w previous process id and the current value, it sends out a email notification to the users. When I try to execute the below code, i am getting the following error server_mon.ksh: line 51: syntax error at line 81: syntax error near unexpected token fi linux `fi' unexpected Code: #!/bin/ksh set ORACLE_HOME=/oracle/product/10.2/bin export ORACLE_HOME LOGON=`cat apps/int/ctrl/orcl_schema.txt` HOSTNAME=`hostname -s` # check for hostname entry in INFA_PROCESS table `sqlplus -s $LOGON << EOF SET SERVEROUT ON SET FEEDBACK OFF SET HEADING OFF SET TIMING OFF SET TERMOUT OFF SET LINES 160 DECLARE v_host_name VARCHAR2(30); BEGIN SELECT host_name INTO v_host_name FROM INFA_PROCESS WHERE host_name = '${HOSTNAME}'; END; / SET SERVEROUT OFF exit EOF` echo $RC RC=$? if [ $RC -eq 0 ] ; then echo "Successfully selected the entry for ${HOSTNAME}in INFA_PROCESS table." else exit 1 fi # Query INFA_PROCESS table for previous values of PMSERVER_PRC_ID and DOMAIN_PRC_ID in INFA_PROCESS table. eval `sqlplus -s $LOGON << ! SET FEEDBACK OFF SET HEADING OFF SET TIMING OFF SET TERMOUT OFF SET LINES 160 SELECT 'export prev_PMSERVER_PRC_ID="' || PMSERVER_PRC_ID || '";' FROM INFA_PROCESS WHERE HOST_NAME = '${HOSTNAME}' UNION SELECT 'export prev_DOMAIN_PRC_ID="' || NVL(DOMAIN_PRC_ID,0) || '";' FROM INFA_PROCESS WHERE HOST_NAME = '${HOSTNAME}'; !` #RC=$? # if [ $RC -ne 0 ] ; then # echo "$0: ERROR! while retrieving the previous PMSERVER_PRC_ID and DOMAIN_PRC_ID for ${HOSTNAME}." # exit 1 # fi echo "Previous PMSERV PRC ID="$prev_PMSERVER_PRC_ID if [$prev_PMSERVER_PRC_ID -eq 0 -o $prev_DOMAIN_PRC_ID -eq 0]; then PMSERVE
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss
Syntax Error Near Unexpected Token For
the workings and policies of this site About Us Learn more about syntax error fi unexpected (expecting then ) Stack Overflow the company Business Learn more about hiring developers or posting ads with us Unix & Linux
Syntax Error Near Unexpected Token Else'
Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join http://www.unix.com/shell-programming-and-scripting/139988-fi-unexpected.html them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top syntax error near unexpected token `fi' up vote -2 down vote favorite I'm getting a syntax error unexpected token fi and Permission denied in the following script: cd /home/NorthStar/Dhruva/server-specific-scripts/crons/ResetETA http://unix.stackexchange.com/questions/247483/syntax-error-near-unexpected-token-fi su postgres -c "psql -d "Dhruva" -f /home/NorthStar/Dhruva/server-specific-scripts/crons/db-connection/query.sql" >> reset.log 2> reset.log if su postgres -c "psql -d "Dhruva" -f /home/NorthStar/Dhruva/server-specific-scripts/crons/db-connection/query.sql; then printf su postgres -c "psql -d "Dhruva" -f /home/NorthStar/Dhruva/server-specific-scripts/crons/db-connection/query.sql\n' >> resset.log else printf su postgres -c "psql -d "Dhruva" -f /home/NorthStar/Dhruva/server-specific-scripts/crons/db-connection/query.sql\n' >> reset_error.log fi shell-script share|improve this question edited Dec 15 '15 at 9:16 asked Dec 5 '15 at 4:08 raj verma 114 why must the lines be so long? also, consider if :; then :; fi >>log –mikeserv Dec 5 '15 at 4:53 or use the character \ for breaking lines so it would be easier to read. –Victor Dec 5 '15 at 6:40 The hint is in the red then and else there. –Stéphane Chazelas Dec 14 '15 at 11:32 You realize you've placed your admin password on the Internet for everyone to see, right? I could edit it out, but the damage has been done. Might want to change it to something else... –Wouter Verhelst Dec 15 '15 at 7:36 add a comment| 1 A
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us http://unix.stackexchange.com/questions/60071/shell-script-syntax-error-near-unexpected-token-done Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody syntax error can answer The best answers are voted up and rise to the top /shell-script: syntax error near unexpected token `done' up vote 1 down vote favorite I am getting syntax error near unexpected token done while executing my shell script: while read filename do echo "$filename" if [ -s $filename ]; then tail -10 $filename | grep `date '+%Y-%m-%d'` >> $lastlines1 echo "- Next Error File - " >> syntax error near $lastlines1 done else echo " no errrors" fi Any ideas, where am I going wrong? shell-script share|improve this question edited Jan 2 '13 at 13:14 mtk 4,170164282 asked Jan 2 '13 at 12:19 UNIX Learner 612 1 some general comments: You probably want to quote any filename variables that might possibly contain spaces. –Gert van den Berg Jan 2 '13 at 12:51 add a comment| 4 Answers 4 active oldest votes up vote 5 down vote you are closing the while before the if. while read filename do echo "$filename" if [ -s $filename ] then tail -10 $filename | grep date '+%Y-%m-%d' >> $lastlines1 echo "- Next Error File - " >> $lastlines1 else echo " no errrors" fi done share|improve this answer answered Jan 2 '13 at 12:23 BitsOfNix 3,162926 add a comment| up vote 3 down vote Let's add some new lines and indentation: 1 while read filename; do 2 echo "$filename" 3 if [ -s $filename ]; then 4 tail -10 $filename | grep date '+%Y-%m-%d' >> $lastlines1 5 echo "- Next Error File - " >> $lastlines1 6 done 7 else 8 echo " no errrors" 9 fi lines 6 and 9 seem to be swapped. In other