Sponsored Content
Full Discussion: Syntax in a simple script
Top Forums UNIX for Beginners Questions & Answers Syntax in a simple script Post 303039697 by ngabrani on Saturday 12th of October 2019 12:19:43 PM
Old 10-12-2019
Syntax in a simple script

I am in the process of writing a script. A very preliminary version is giving a syntax error. The script is
Code:
#!/bin/bash
#file1='./data/heu/hout1'

exec 10<&0
exec < './data/heu/hout1'
#file1='./data/heu/hout1-
i=1
j=0
while read file1
do


	echo $file1
	echo $i
	if[$i==1] then
		arr1[$j]=file1
		$((i++))
	elif[$i==2] then
		arr1[$j]=file1
		$((i++))
	else
		$i=0
		$((j++))
	fi
done

The following errors get generated
Code:
line 21: syntax error near unexpected token `else'

Appreciate any inputs.
Moderator's Comments:
Mod Comment Use code tags to wrap code fragments or data samples

Last edited by Yoda; 10-12-2019 at 01:25 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Syntax error in a script...

Hi All, I have been fighting with a syntax error for the last 2 days, still haven't got the solution. Could you please help me, your help will be greatly appreciated. In my script I am getting a error in a for loop, its similar to the one as is below. for v_id in v1 v2 v3 v4 do... (8 Replies)
Discussion started by: rajus19
8 Replies

2. Shell Programming and Scripting

Syntax error in script

I get this error when I try to run my script (BTW, this is a simple script I am supposed to write for my class) $ menuscript menuscript: syntax error at line 89 : `"' unmatched $ Here is the code (Any help is greatly appreciated) (Line numbers included) 1 #!/bin/ksh 2 ... (2 Replies)
Discussion started by: KindHead
2 Replies

3. Programming

Tools for writing a simple syntax checker?

I'm trying to write a small utility for syntax checking. I've tried using Flex/Bison, but these seem too advanced for my task. A simpler tool would be appreciated. (1 Reply)
Discussion started by: Ilja
1 Replies

4. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

5. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

6. UNIX for Dummies Questions & Answers

Syntax Error Script

Hi guys i'd like to show you this code of my script, where i couldn't find this error " #! /bin/bash #copiabin.sh: copia todos los archivos ejecutables a bin if then mkdir $HOME/bin fi # copia de archivos y contador N N=0 for ARCH in * do if # Si el archivo es... (9 Replies)
Discussion started by: Newer
9 Replies

7. Shell Programming and Scripting

CHECK SCRIPT SYNTAX

Hi everyone, i'd like someone chechk this script, i know it's very simple but it doesn't work good, let me tell you this script works over huge directories, maybe that's the problem, if somebody can give me other way to develop, or show me where it's the problem, i'll appreciate it. ... (9 Replies)
Discussion started by: Newer
9 Replies

8. Shell Programming and Scripting

Help Simple FTP Script Here Syntax

I have a list of IP address and want to be assess whether FTP is allowing FTP access. I don't want to use lousy NT shell, but cannot get the syntax down on this. ftphosts.txt is a simple list of IP adresses. I want to iterate through the IPS and do a simple ftp IPadress user ftp password... (15 Replies)
Discussion started by: gdotoli
15 Replies

9. Linux

How to execute a simple select script using a shell script?

Hi team, I have two select statements and need to run them using SYSDBA user select * from temp_temp_seg_usage; select segment_name, tablespace_name, bytes/ (1024*1024) UsedMb from dba_segments where segment_name='TEMP_TEMP_SEG_USAGE'; Need to run this using a shell script say named... (1 Reply)
Discussion started by: pamsy78
1 Replies

10. Shell Programming and Scripting

Script syntax help

#!/bin/bash if ; then echo "Lipsa IP"; exit; fi i=1 ip=$1 while ; do if ; then rand=`head -$i pass_file | tail -1` user=`echo $rand | awk '{print $1}'` pass=`echo $rand | awk '{print $2}'` CMD=`ps -eaf | grep -c mysql` if ; then ./mysql $ip $user $pass & else sleep 15... (6 Replies)
Discussion started by: galford
6 Replies
INITSCRIPT(5)						Linux System Administrator's Manual					     INITSCRIPT(5)

NAME
initscript - script that executes inittab commands. SYNOPSIS
/bin/sh /etc/initscript id runlevels action process DESCRIPTION
When the shell script /etc/initscript is present, init will use it to execute the commands from inittab. This script can be used to set things like ulimit and umask default values for every process. EXAMPLES
This is a sample initscript, which might be installed on your system as /etc/initscript.sample. # # initscript Executed by init(8) for every program it # wants to spawn like this: # # /bin/sh /etc/initscript <id> <level> <action> <process> # # Set umask to safe level, and enable core dumps. umask 022 ulimit -c 2097151 PATH=/bin:/sbin:/usr/bin:/usr/sbin export PATH # Increase the hard file descriptor limit for all processes # to 8192. The soft limit is still 1024, but any unprivileged # process can increase its soft limit up to the hard limit # with "ulimit -Sn xxx" (needs a 2.2.13 or later Linux kernel). ulimit -Hn 8192 # Execute the program. eval exec "$4" NOTES
This script is not meant as startup script for daemons or somesuch. It has nothing to do with a rc.local style script. It's just a handler for things executed from /etc/inittab. Experimenting with this can make your system un(re)bootable. FILES
/etc/inittab, /etc/initscript. AUTHOR
Miquel van Smoorenburg ,<miquels@cistron.nl> SEE ALSO
init(8), inittab(5). July 10, 2003 INITSCRIPT(5)
All times are GMT -4. The time now is 09:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy