Sponsored Content
Top Forums Shell Programming and Scripting Errors in bash with if statements Post 302360806 by bbbash on Saturday 10th of October 2009 01:06:54 PM
Old 10-10-2009
Errors in bash with if statements

Hello everyone,
I got this type of error when programming in bash
new.bat: 16: cannot create : Directory nonexistent
$bool
new.bat: 37: Syntax error: "then" unexpected (expecting "fi")
Does anyone know why?
Here is my code

#!bin/bash
#function helps(){
#echo "$ compile -o filename -clean -backup - archive -help cfilenames"
#echo "-o Filename : the mandatory argument that indicates the compiled executable name."
#echo "-clean : remove all.o files in backup"
#echo "-backup : copy all files in Backup folder from C"
#echo "-archive : tar the Source directory and move the tar to Backup folder"
#echo "-help : display this help information"
#}
s1='h'
s2='clean'
s3='backup'
s4='archive'
bool=''
echo $1 >File.txt
grep "o " File.txt > $bool
echo '$bool'
if [ bool = '' ];
then
rm -f -r File.txt
echo "Argument -o is mandatory"
echo "help menu"
echo "$ compile -o filename -clean -backup - archive -help cfilenames"
echo "-o Filename : the mandatory argument that indicates the compiled executable name."
echo "-clean : remove all.o files in backup"
echo "-backup : copy all files in Backup folder from C"
echo "-archive : tar the Source directory and move the tar to Backup folder"
echo "-help : display this help information"
fi
if [ bool != ''];
then
rm -f -r File.txt
echo "write the path of your C file please."
read filename
gcc filename $1
if[$s1=$1 -o $s1=$s2 -o $s1=$3 -o $s1=$4 -o $s1=$5];
then
echo "help menu"
echo "$ compile -o filename -clean -backup - archive -help cfilenames"
echo "-o Filename : the mandatory argument that indicates the compiled executable name."
echo "-clean : remove all.o files in backup"
echo "-backup : copy all files in Backup folder from C"
echo "-archive : tar the Source directory and move the tar to Backup folder"
echo "-help : display this help information"
fi
if[$s2=$1 -o $s2=$s2 -o $s2=$3 -o $s2=$4 -o $s2=$5];
then
cd ~/Projects/Store/Backup
rm -f -r *.o
fi
if[$s3=$1 -o $s3=$2 -o $s3=$3 -o $s3=$4 -o $s3=$5 -o $s3=$6];
then
cd ~/Projects/Store/Build1/Source/C
mv -f *.o *.h ~/Projects/Store/Backup
fi
if[$s4=$1 -o $s4=$2 -o $s4=$3 -o $s4=$4 -o $s4=$5 -o $s4=$6];
then
cd ~/Projects/Store/Build1/Source
tar -cvvf Source.tar Source/
fi
fi
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Adapter Errors and Link Errors

$ errpt | more IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION 3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR 3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR B8113DD1 ... (0 Replies)
Discussion started by: mcastill66
0 Replies

2. UNIX for Advanced & Expert Users

Bash/Unix Command Errors

Hi all, I have major errors on entering the shell. On login I get: -bash: dircolors: command not found -bash: tr: command not found -bash: fgrep: command not found -bash: grep: command not found -bash: grep: command not found -bash: id: command not found -bash: # root@host # pwd /bin... (0 Replies)
Discussion started by: wcmmlynn
0 Replies

3. UNIX for Dummies Questions & Answers

Major OS errors/Bash errors help!!!!

Hi all, dummy here.... I have major errors on entering the shell. On login I get: -bash: dircolors: command not found -bash: tr: command not found -bash: fgrep: command not found -bash: grep: command not found -bash: grep: command not found -bash: id: command not found -bash: [: =: unary... (12 Replies)
Discussion started by: wcmmlynn
12 Replies

4. Shell Programming and Scripting

Multiple If statements in bash problem

Hi everyone, May you help me with the correct syntax of the follow bash statements please X=10 if ]; then echo "The value is between 1 and 5" for ((i=1;i<=${X})); do echo $i done else if ]; then echo "The value is between 6 and 10" for ((i=1;i<=${X})); do ... (5 Replies)
Discussion started by: Ophiuchus
5 Replies

5. Shell Programming and Scripting

Bash if statements in one line

I have the following bash code, and wondering if it is possible (and a good idea) to write the if statements in one line. # Run raytrac on the sound speed model. if ; then $bashPath/raytrac.bash -fcmd=$fcmd.cmd fi # Plot the travel times and ray paths. if ; then ... (8 Replies)
Discussion started by: kristinu
8 Replies

6. Shell Programming and Scripting

Bash script errors when executing

I'm working on a script that will search through a directory for MKV files and remux them to MP4. I found a few other scripts around the net that do this, but they all have limitations that don't always get the job done. The main limitation I've found is that most scripts look for the video track... (2 Replies)
Discussion started by: rayne127
2 Replies

7. Shell Programming and Scripting

Converting from Linux bash (GNU) to Solaris script syntax errors

Original script written on CentOS 6.3 with GNU bash 4.1.2 Destination system is Solaris 9 with GNU bash 2.05 (not changeable by me) I have a script written on the linux side but now we need to provide a version to another site that "doesn't like linux". I've been going through changing the ] or... (13 Replies)
Discussion started by: oly_r
13 Replies

8. Ubuntu

Bash to Ash, errors and adjustments

I wrote Bash script and now I want to convert it to Ash. One headache is this function: do_adduser() { setaddprompt _arr_add=("Add manually" "Add via TXT" "return to main menu" "exit program") select add_action in "${_arr_add}" do case "$REPLY" in 1)... (7 Replies)
Discussion started by: fzivkovi
7 Replies

9. Shell Programming and Scripting

Equivalence of "if then" statements in bash

Would these two sections of code be equivalent? The original is the first one, followed by the new implementation. if ; Then ... else if ; Then ... fi fi if ; Then ... else if ; Then ... fi (4 Replies)
Discussion started by: kristinu
4 Replies

10. Shell Programming and Scripting

New bash menu printing errors but closes too quickly

I am beginning to write a new version of the bash menu below. The previous version worked great and now when I start the updated bash it opens and a some lines print in the terminal and it closes quickly. I know there are errors but how can I see them or fix them, I tried set -x with the same... (12 Replies)
Discussion started by: cmccabe
12 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.11 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 05:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy