Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Syntax error: unexpected 'else' Post 303045176 by Syedsabeel on Friday 13th of March 2020 03:16:29 AM
Old 03-13-2020
Syntax error: unexpected 'else'

Im trying to pause my script for 23:59 to 6am but it is throwing error:
Code below:
Code:
#!/system/bin/sh

while true
do
TIME=$(date '+%H%M%S')
if [ $TIME -ge 235900 ] -a [ $TIME -le 060000 ]
then*
echo "time between  noon and morning"*
echo sleep time $TIME
sleep 3
else
then
echo "time all others"
fi
done

Moderator's Comments:
Mod Comment
Please wrap all code, files, input & output/errors in CODE tags.
It makes it far easier to read and preserves spaces for indenting or fixed-width data.

Last edited by rbatte1; 03-13-2020 at 09:54 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sh: syntax error: `...' unexpected???

Hello all, I want to create a script that polls every hour a directory for the existence of a file. The file I look for is a `token` dropped by an external process at the completion of a successful FTP process. I wrote this script `checkfile.ksh`: #!/usr/bin/ksh if ] then mailx... (5 Replies)
Discussion started by: alan
5 Replies

2. Shell Programming and Scripting

unexpected syntax error

Hi, i am getting following syntax error ...kingly advice why is it coming ?? #!/bin/bash find . -name "common.log" if ; then echo "1" fi Himnashu@home /bin $ ./a.sh ./a.sh: line 7: syntax error near unexpected token `fi' ./a.sh: line 7: `fi' (9 Replies)
Discussion started by: himvat
9 Replies

3. Shell Programming and Scripting

syntax error: `$' unexpected

Hi all, Am very new to Unix and am currently Involved in Migrating some Shell Scripts from AIX 4 to Solaris 10. While using teh for loop am getting the below error: $ echo $SHELL /usr/bin/ksh $ for file in $(ls *SEBE*) syntax error: `$' unexpected while the same works without issue on... (4 Replies)
Discussion started by: paragkhanore
4 Replies

4. Shell Programming and Scripting

ksh syntax error: `(' unexpected

So I am trying to convert my bash script into ksh, and this is what I have in the file so far: #!/bin/ksh login() { if then sendcmd BETA else sendcmd "$(xxd -c 32 -g 0 ${ZETA_ZETA} | awk '{print $2}')" fi } But when I run it: $ ./test.sh ... (1 Reply)
Discussion started by: guitarscn
1 Replies

5. Shell Programming and Scripting

Help with ksh syntax error Unexpected Fi

Issue resolved, thanks (6 Replies)
Discussion started by: dangell82
6 Replies

6. Shell Programming and Scripting

Syntax error: 'fi' unexpected

unzip file.zip if ] ; then echo "Success" else echo "Some failure." fi ; I tried many time to detect the unzip error, but it keep show the syntax error wherever how I change the syntac. Hope someone can help me fix the issue, thanks. Please use code tags next time for your code and... (5 Replies)
Discussion started by: duncanyy
5 Replies

7. Shell Programming and Scripting

Syntax error `(' unexpected

I have written this in my script but while running i am getting syntax error `(' unexpected. unload to "$BACKUP_DIR/n_fac_fid-$clliname" select * from n_fac_fid where fac_accesskey in (select fac_accesskey From n_fac_ap_fid where ap_clli="$clliname"); Any help appreciated. (3 Replies)
Discussion started by: suryanmi
3 Replies

8. UNIX for Beginners Questions & Answers

Syntax error near unexpected token

Dears, While executing the below script im getting the error at line 30. Please let me know what changes to be done to fix this. test.sh: line 30: syntax error near unexpected token `done' test.sh: line 30: ` done ' #!/bin/sh # Rev. PA1 # author: eillops # date: 26-04-2018 # #... (1 Reply)
Discussion started by: Kamesh G
1 Replies

9. Shell Programming and Scripting

Syntax error: `]' unexpected

I am getting this error Syntax error: `]' unexpected. Did I do something wrong with elif? Does ksh not like double brackets? if ]; then #echo hi source ~/.bashrc; elif ]; then #echo hi source ~/.kshrc; fi (5 Replies)
Discussion started by: cokedude
5 Replies

10. Shell Programming and Scripting

Syntax error: Unexpected '('

I've been trying to figure this issue for almost 2 hours now... I dont see/find any typos or other code mismatches.. but maybe i'm looking at the wrong places.... Here's the console output: $ LC_ALL=C $ cd prjs/SWARM/ ; time source ./rc bash: cd: prjs/SWARM/: No such file or directory... (3 Replies)
Discussion started by: sea
3 Replies
At(3pm) 						User Contributed Perl Documentation						   At(3pm)

NAME
Schedule::At - OS independent interface to the Unix 'at' command SYNOPSIS
require Schedule::At; Schedule::At::add(TIME => $string, COMMAND => $string [, TAG =>$string]); Schedule::At::add(TIME => $string, COMMAND => @array [, TAG =>$string]); Schedule::At::add(TIME => $string, FILE => $string) %jobs = Schedule::At::getJobs(); %jobs = Schedule::At::getJobs(JOBID => $string); %jobs = Schedule::At::getJobs(TAG => $string); Schedule::At::readJobs(JOBID => $string); Schedule::At::readJobs(TAG => $string); Schedule::At::remove(JOBID => $string); Schedule::At::remove(TAG => $string); DESCRIPTION
This modules provides an OS independent interface to 'at', the Unix command that allows you to execute commands at a specified time. Schedule::At::add Adds a new job to the at queue. You have to specify a TIME and a command to execute. The TIME has a common format: YYYYMMDDHHmm where YYYY is the year (4 digits), MM the month (01-12), DD is the day (01-31), HH the hour (00-23) and mm the minutes. The command is passed with the COMMAND or the FILE parameter. COMMAND can be used to pass the command as an string, or an array of commands, and FILE to read the commands from a file. The optional parameter TAG serves as an application specific way to identify a job or a set of jobs. Returns 0 on success or a value != 0 if an error occurred. Schedule::At::readJobs Read the job content identified by the JOBID or TAG parameters. Returns a hash of JOBID => $string where $string is the the job content. As the operating systems usually add a few environment settings, the content is longer than the command provided when adding the job. Schedule::At::remove Remove an at job. You identify the job to be deleted using the JOBID parameter (an opaque string returned by the getJobs subroutine). You can also specify a job or a set of jobs to delete with the TAG parameter, removing all the jobs that have the same tag (as specified with the add subroutine). Used with JOBID, returns 0 on success or a value != 0 if an error occurred. Used with TAG, returns a hash reference where the keys are the JOBID of the jobs found and the values indicate the success of the remove operation. Schedule::At::getJobs Called with no params returns a hash with all the current jobs or dies if an error has occurred. It's possible to specify the TAG or JOBID parameters so only matching jobs are returned. For each job the key is a JOBID (an OS dependent string that shouldn't be interpreted), and the value is a hash reference. This hash reference points to a hash with the keys: TIME An OS dependent string specifying the time to execute the command TAG The tag specified in the Schedule::At::add subroutine Configuration Variables o $Schedule::At::SHELL This variable can be used to specify shell for execution of the scheduled command. Can be useful for example when scheduling from CGI script and the account of the user under which httpd runs is locked by using '/bin/false' or similar as a shell. EXAMPLES
use Schedule::At; # 1 Schedule::At::add (TIME => '199801181530', COMMAND => 'ls', TAG => 'ScheduleAt'); # 2 @cmdlist = ("ls", "echo hello world"); Schedule::At::add (TIME => '199801181630', COMMAND => @cmdlist, TAG => 'ScheduleAt'); # 3 Schedule::At::add (TIME => '199801181730', COMMAND => 'df'); # This will remove #1 and #2 but no #3 Schedule::At::remove (TAG => 'ScheduleAt'); my %atJobs = Schedule::At::getJobs(); foreach my $job (values %atJobs) { print " ", $job->{JOBID}, " ", $job->{TIME}, ' ', ($job->{TAG} || ''), " "; } AUTHOR
Jose A. Rodriguez (jose AT rodriguez.jp) perl v5.14.2 2012-04-24 At(3pm)
All times are GMT -4. The time now is 06:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy