Sponsored Content
Homework and Emergencies Homework & Coursework Questions Help fixing my database script Post 302867163 by gamernerd101 on Wednesday 23rd of October 2013 02:35:59 PM
Old 10-23-2013
Help fixing my database script

1. The problem statement, all variables and given/known data:
I need help I get a variant of syntax errors when compiling my script to maintain a database. It's a simple database meant to create/view/maintain vehicles.


2. Relevant commands, code, scripts, algorithms:
my if statements have many syntax errors and I'm lost as to why. One key lines is line 8 my first if statement. Thanks in advance.


3. The attempts at a solution (include all code and scripts):
Code:
#! /bin/bash
# Automobile database

db=arg1
command=arg2
case $db in
    #create:
if [ -f "$db" ]; then
echo "DATABASE EXSISTS"

 if [ $arg3 != "" ]
 echo $arg3 > db

else
echo "Automobile Database" > db
echo "New database created"
fi
  esac

#add

read -p "Make of the car: " make

read -p "Model of the car: " model

read -p "Year of the car: " year

read -p "Color of the car: " color


if $year < 1870 || $year > 2020
echo "Error with $year"
fi
echo "$make, $model, $year, $color" >> db
echo "Successfully added a record to the database"

case $arg3:
 max=$( wc -l db )
 #all:
 cat db

 if $arg4 > $max
 echo "Error"
 fi
 sed -ne "1p;arg4p" db

#range:
if $arg4 > $max || $arg5 > $max || $arg4 > $arg5
error
fi
sed -ne "1p;arg4,arg5p" $db
esac



#delete:
        case $arg3:
        max=$( wc -l db )
      sed -ie '2,$d' db
     single:
     if $arg4 > $max
     echo "error"
     fi

     sed -ie "$arg4d" db


     range:
     if $arg4 > $max || $arg5 > $max || $arg4 > $arg5
           echo "Error"
           fi
     sed -ie "arg4,arg5d" db
esac


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
NIU, dekalb il USA, Ege, CSCI 330

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies

2. Linux

fixing with sed

I am trying to replace the value of $f3 but its not working . I don't know what I am missing here . cat dim_copy.20080516.sql | grep -i "create view" | grep -v OPSDM002 | while read f1 f2 f3 f4 f5 f6 f7 f8 f9 do echo " $f3 " sed -e... (13 Replies)
Discussion started by: capri_drm
13 Replies

3. Shell Programming and Scripting

Fixing corrupted vcard files.

KDE's Kontact PIM breaks quoted-printable vcard files because it linebreaks in the middle of a word. Take this text for example: NOTE;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=D7=A9=D7=95=D7=A8=D7=94 =D7=A 8=D7=90=D7=A9=D7=95=D7=A0=D7=94.\n=D7=94=D7=A9=D7=95=D7=A8=D7=94 =D7=94=D7= ... (7 Replies)
Discussion started by: dotancohen
7 Replies

4. Shell Programming and Scripting

Fixing the width of a word

Is there a way to fix the width of the word being printed to a file? I am trying to create an output to a file with columns , like a spread sheet. I have used "\t" to adjust the columns but still it does not show well in the file, mainly due to the variable length values in the column so \t does... (1 Reply)
Discussion started by: davidtd
1 Replies

5. Shell Programming and Scripting

help fixing awk statement

awk "BEGIN {if($MessageREAD<$ThresholdW) {print \"OK\" ; exit 0} else if(($MessageREAD>=$ThresholdW) && ($MessageREAD<$ThresholdC)) {print \"WARNING\" ; exit 1}" else if($MessageREAD<=$ThresholdC) {print \"CRITICAL\" ;... (4 Replies)
Discussion started by: SkySmart
4 Replies

6. AIX

Fixing security problem

Hi I use Rapid 7 to check some servers ( AIX 5.3 ) for security problems. There are 2 problems I don't know to deal with 1. Problem : TCP Sequence Number Approximation Vulnerability Solution : _Enable TCP MD5 Signature 2. Problem : HTTP Basic Authentication Enable Solution : _ Use... (5 Replies)
Discussion started by: bobochacha29
5 Replies

7. Shell Programming and Scripting

Fixing a shell script

I have this shell script that I wrote to check an input file to see if it is empty or not, and then clean the file from any line that starts with the sign "<" (without quotation marks" and then spell the number of line of the file, and the empty lines, too. The script then will create two output... (11 Replies)
Discussion started by: faizlo
11 Replies

8. UNIX for Advanced & Expert Users

Help with fixing screen position

Hey guys, I am trying to make print a pattern with * on a 10*10 two dimensional array in a for loop and I want the incoming 10*10 to overlap the previous 10*10 so that the * look like it is moving. is there a way to fix the screen position? ever time it prints a 10*10 the screen moves. ... (3 Replies)
Discussion started by: amit14august
3 Replies

9. Shell Programming and Scripting

Help fixing awk code

can someone please help me spot and fix the issue with the following code: awk -F, -v SEARCHPATT="(Wed|Tue)" -v ADDISTR="Mon|Tue|Wed|Thu|Fri|Sat|Sun" -vVF="$VALFOUND" "BEGIN{ {D = D = 1 D = D = 2 } $0 ~ "," VF "," {L = 1 ... (9 Replies)
Discussion started by: SkySmart
9 Replies
shevek::ristring(3)					     Library Functions Manual					       shevek::ristring(3)

NAME
shevek::ristring - shevek::ristring is identical to shevek::istring, but it uses std::string instead of Glib::ustring. SYNOPSIS
#include <iostring.hh> Public Member Functions ristring () Create a new istring with no data. ristring (std::string const &str) Create a new istring with data. void init (std::string const &str) Set new data to an existing istring. void push () Push the current position to the stack so it can be restored later. int pop (bool keep=false) Pop the last pushed position from the stack. void reset () Set the current position to 0, but don't change the stack. std::string rest () const Get remaining string. void skip (std::string::size_type p) Skip some characters. bool operator() (std::string const &format) Read a constant string from the input. template<typename T1 > bool operator() (std::string const &format, T1 &arg1) Read a string containing one argument from the input. template<typename T1 , typename T2 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2) Read a string containing two arguments from the input. template<typename T1 , typename T2 , typename T3 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3) Read a string containing three arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4) Read a string containing four arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5) Read a string containing five arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6) Read a string containing six arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6, T7 &arg7) Read a string containing seven arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 > bool operator() (std::string const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6, T7 &arg7, T8 &arg8) Read a string containing eight arguments from the input. Static Public Member Functions template<typename T > static T direct (std::string const &data, std::string const &format, T def=T()) Read a variable from given data and return it. Detailed Description shevek::ristring is identical to shevek::istring, but it uses std::string instead of Glib::ustring. Member Function Documentation template<typename T > static T shevek::ristring::direct (std::string const &data, std::string const &format, Tdef = T ()) [inline, static] Read a variable from given data and return it. This allows using a shevek::istring in an expression without the need to create a new variable for it. If the input doesn't match the format, def is returned. int shevek::ristring::pop (boolkeep = false) Pop the last pushed position from the stack. If keep is true or not given, the current position is restored to the last position. If it is false, the current position is not changed. Author Generated automatically by Doxygen for libshevek from the source code. libshevek Fri May 11 2012 shevek::ristring(3)
All times are GMT -4. The time now is 10:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy