Bourne shell script

  • Permalink
  • submit to reddit
  • Email
  • Follow


I need a bourne shell script that reads a test case from the input
data file and compare it to its corresponding output. If there is a
difference,the script must print the line number of the input test
case in a result file. Script output and the expected output( givenin
a file called output.txt ) must be compared using "diff" utility.

The purpose of thisscript is black box testing:

thank you in advance
0
Reply ibbu79 7/22/2003 7:21:46 PM

See related articles to this posting


Excluded_Middle wrote:

> Alan Connor <xxxxxx@xxxx.xxx> wrote in message news:<klgTa.16937$Mc.1287821@newsread1.prod.itd.earthlink.net>...
> 
>>On 22 Jul 2003 12:21:46 -0700, Excluded_Middle <ibbu79@hotmail.com> wrote:
>>
>>>I need a bourne shell script that reads a test case from the input
>>>data file and compare it to its corresponding output. If there is a
>>>difference,the script must print the line number of the input test
>>>case in a result file. Script output and the expected output( givenin
>>>a file called output.txt ) must be compared using "diff" utility.


If the program to test reads from standard input:

#!/bin/ksh

integer line=0
while read test_case; do
   print -- "$test_case" |
   program_to_test |
   diff expected_output_file - |
   sed -e "s/^/line number $line: /"
   ((integer += 1))
done < input_data_file

If the program to test reads command line arguments, replace

   print -- "$test_case" | program_to_test | ...

with

   program_to_test $test_case | ...


>>I am going to save you, perhaps, from getting your ears boxed here:
>>
>>This ng is not a script dispensary, but, actually, a college of sorts, where
>>shell masters teach. (and some novices, like me, occassionally play at it :-)
>>
>>If you just want a script but don't want to learn shell scripting, then hire
>>one of the pros here.
> 
> People like you can help me alot by not participating in the
> discussion. If you don't know the how to do it then please don't reply
> to the group.


You're the one who doesn't know how to do it, or how to go about
asking for help doing it.


>>Otherwise, work through one of the many fine tutorials available*, do the best
>>you can at writing the script you want, THEN post it and ask for help.
> 
> I'll do that even if you don't advise me but everything take some
> time.


You posted before you even took the time to do `man diff`.


-- 
Kevin Rodgers

0
Reply Kevin 7/23/2003 11:51:57 PM
comp.unix.shell 15063 articles. 25 followers. Post

1 Replies
207 Views

Similar Articles

[PageSpeed] 8


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Bourne shell script to determine users shell
All, As root, I would like to get the shell and home directory of any user. I know I can grep it out of /etc/passwd -OR- ypcat passwd but what if the authentication is via ldap? What I am looking for is a implementation similar to getpwent() system call. Is it possible in bourne shell? Please explain. Chandrashekar Tippur In article <1111008774.484325.132650@o13g2000cwo.googlegroups.com>, "Shekar" <ctippur@msn.com> writes: > All, > > As root, I would like to get the shell and home directory of any user. > I know I can grep it out of /etc/passwd -OR- ypcat...

bourne shell script
is there a way to test that something work ie if I diff 2 files is there any way in the script to tell if the files were the same Greg wrote: > is there a way to test that something work ie if I diff 2 files is there any > way in the script to tell if the files were the same Thats what program return codes are for; diff has the following return codes: 0 No differences were found. 1 Differences were found. >1 An error occurred. After executing a program, it's return code is stored in the $? variable, so: #!/bin/sh diff a b > /dev/null i...

bourne shell script help
Greetings, I'm trying to write a script that will find the executable files, but not directories, in a user's path statement. Does anyone have a starting point or a differing perspective than what I have here? I'm having difficulty getting this to run. Thanks in advance! #!/bin/sh # set a flag to check if you should search all for all ocurrences of the command # by default only find the first occurance FINDALL=FALSE while: do case $1 in $PATH -a) FINDALL=TRUE shift # throw away this argument ;; -h) echo "Usage: $0 [ -a ] comm...

Bourne Shell Scripting with iptables
hey guys. we are working on a new implementation of iptables where our customers can = specify simplified options in a config file. now i need to write a script that will parse the config file, assign all th= e variables, and write all the rules in iptables.=20 the syntax that the customer will use looks like this: accept|drop|reject (in|out) (on <interface> (ipv[46])) (proto <protocol>) (= from (source) port <port>) (to (dest) port <port>) everything between () is optional. so only accept,drop or reject are requir= ed.. thats the tricky thing.. the c...

Bourne shell sed script help
I need to write a Bourne Shell script to prepare a string for insertion into SQLite. Below is my nearly successful script to format it how it needs to be, but I can't quite get it right. The script should be self-explanatory. I'm not wedded to sed if awk or tr or... will succeed. Thanks! #! /bin/sh # S="\"text in quotes\" ; {\i text in italics} and special character {\'e9} text" echo "Starting text. Prepare for an SQLite string update insertion argument." echo "${S}" # echo " " echo "final text required (here resorted to enc...

dd(1) as bourne shell script
Hi, I was trying to implement a crude dd(1) in a strictly shell-script, but it seems it can't distinguish between nul and newline. Any ideas? I don't think it can be done. Here's the script: #!/bin/bash function dd_func () { while IFS= read -r -n 1 c do if [ -z "$c" ] then # What to do? Can be either # nul (\000) or newline (\011) : else echo -En "${c}" fi # Do some stuff based on $c # or file offset here. done } dd_func < $1 bjd Bauke Jan Douma wrote: > Hi, > > I was trying to implement a crude dd(1) in a stri...

bc in bourne shell script question
I'm using the following construct to convert decimal to hexadecimal; H1=`echo "ibase=10; obase=16; $D1"| bc` It would appear to work great. My problem is when it is converting a singe digit number - it outputs a single digit number, I would like it padded with a zero, ie 6 becomes 06, etc. Is there a way to do this within my bc construct or am I going to have to do some shell scipt funkyness. Thanks in advance, David On Thu, 17 Mar 2005 at 16:15 GMT, David McWilliams wrote: > I'm using the following construct to convert decimal to hexadecimal; > > H1=`echo &...

Bourne Shell Script Newbie Help
Hello Group, I need some assistance in starting an assignment. I have never programmed in Unix let alone shell scripting. I searched the internet to find similar problems to mine when I came accross this. So could you aid me in starting this problem. Thank you. Heres the problem: Overview In this assignment you will write a Bourne shell script to calculate averages and medians from an input file of numbers. This is the sort of calculation I might do when figuring out the grades for this course. The input file will have whole number values separated by tabs, and each line of this file wil...

Can I Inline a Bourne/C shell script?
Hi all, 1. Is it possible to inline a sh/csh script from a Perl program. I realize, I can run the shell script as, system("Foo.sh") ; but I want all the variables I set in my Perl program to be available to Foo.sh. 2. Failing that, is there a way I can 'export' all the variables I set in Perl to Foo.sh? Thanks for your time, Prabh Prab_kar@hotmail.com wrote: > 1. Is it possible to inline a sh/csh script from a Perl program. > I realize, I can run the shell script as, > system("Foo.sh") ; > but I want all the variables I set in my Perl program to be ...

getting env variable from bourne shell script
Hello, I have file called PARAMETRES that is used in bourne shell script to define variable. In order to do so I put a ". PARAMETRES" line and the script has acces to all the variable defined in the PARAMETRES file. Now, I would like to be able to get the same thing in python. I googled and played with os.system to try to come up with something but no success so far. I also tryed exec but it doesn't work becaus a lot of string variable difined in the PARAMETRES file do not have the ' sign needed in python string. for example. Let's say I have a file PARAMETRES co...

bourne shell script command line argument
Hi there, My question is I have to write a script name s1.sh such that: $ s1.sh $ s1.sh -h $ s1.sh -How $ s1.sh -hello in all the above cases the script should print: Usage: s1.sh ARG1 AGR2 ... I did the first 2 by following method: #!/bin/sh MSG=Usage: s1.sh ARG1 AGR2 ... if [ $# < 1 ]; then echo $MSG exit 1 elif [ $1 == "-h" ]; then echo $MSG exit 1 fi how to make condition for -how or -HOW or -hello etc... On Wed, 09 Jul 2003 at 17:09 GMT, Excluded_Middle wrote: > Hi there, > My question is I have to write a script name s1.sh such that: > > $ s...

Date conversion in Bourne shell script question
Hi, I am writing an account audit script which will need to calculate number of days between today and some date in the past represented by standards date string, something like: Wed Feb 4 13:17:52 EST 2004. I need a function to convert in to UNIX epoch time so I can calculate a difference and convert it back to number of days. I am limiting myself to Bourne shell and awk, because I want the same script to run on HP-UX, Solaris and AIX. I am sure it is not a new problem, but I cannot find any references on that. I would be greatfull if you can point me in the right direction. Thanks in adv...

quoting quotes withion a (bourne shell) script line
Hopefully an easy one but I'm tearing my hair out. Keeping a long story short, I have a NetAPP filer with (lets say) root access of username : root password : nobby' (the end ' is supposed to be there). Our backup software using NDMP has thism information in its configuration. Meanwhile I need to move data from the filer above to anothjer, for which I would enter - on a command line from the second filer - ndmpcopy -sa root:"nobby'" filer1:/vol/vol0/data/fred /vol/vol0/data/fred where the double quotes indicate that the strting within is the password. I can o...

bourne shell script doesn't complete without -x
I have a script that suddenly stopped working after I modified it to do sleep commands of 4 and 2 seconds prior to and after a daemon restart. Since then, it only completes when I use -x to watch it execute. Is there something I am unaware of that causes this behavior? Thx. Jack Shown <jackshown@gmail.com> wrote: > I have a script that suddenly stopped working after I modified it to > do sleep commands of 4 and 2 seconds prior to and after a daemon > restart. Since then, it only completes when I use -x to watch it > execute. Is there something I am unaware of that caus...

Problem: script written and invoked shows bourne shell has varying file size
Hello, I was writing a script yesterday that goes and searches popular shell locations and within those all shells and reports ls -l output on them. What it produced concerned me. In two locations, the bourne sh has two different file sizes. Now CERT usually reccommends that you compare the system against known media. How exactly is this done? I have the distribution on CD, and have superuser access to the system. My thought was that I'd print the output of the script, go to the server room and pull the server down into single user mode, mount the CD, and (hopefully I could then) do...

execute a shell script in a shell script
Please help. I have been stumbled on this issue, please see below. I am unable to execute a shell script in a shell script. I need to use perl script but not others and have tried eval, -exec and other on perl script but failed. system"cleartool setview -exec \"cleartool describe -fmt 'On %Sd modified %En and comment:\n %c\n\n' /myproject/vob/myprogram.C\" my_lag "; tks. On Dec 3, 8:30 am, moongeegee <moongee...@gmail.com> wrote: > Please help. > I have been stumbled on this issue, please see below. I am unable to > execute a shell script in a shel...

Convert Bash shell script to Korn shell script
The following bash script works fine to delete all files that are older than $1 minutes. To execute this script, bash cleanup +10 find /mypath -type f -cmin $1 -exec rm -f {} \; Unfortunately, now I just realize I need to make it work in Korn Shell. Even I change the header from #!/bin/bash to #!/usr/bin/ksh, and execute the script by ksh cleanup +10, it still have different errors: cleanup[9]: -cmin: not found. cleanup[10]: -type: not found. Looks like it doesn't work anymore. I think I need to re-write the Korn Shell script that do the task. I tried to search for equivalent Korn ...

Convert Bash shell script to Korn shell script
The following bash script works fine to delete all files that are older than $1 minutes. To execute this script, bash cleanup +10 find /mypath -type f -cmin $1 -exec rm -f {} \; Unfortunately, now I just realize I need to make it work in Korn Shell. Even I change the header from #!/bin/bash to #!/usr/bin/ksh, and execute the script by ksh cleanup +10, it still have different errors: cleanup[9]: -cmin: not found. cleanup[10]: -type: not found. Looks like it doesn't work anymore. I think I need to re-write the Korn Shell script that do the task. I tried to search for equivalent Korn ...

handling SIGINT in shell scripts when executing another shell script.
I have a simple shell script foo1.sh that invokes another shell script foo2.sh, something like below: #!/bin/sh SIGINT_handler() { echo "## [$DATE_TIME] User interrupt ignored," continue } trap SIGINT_handler 2 .... ../foo2.sh .... ---------- while executing foo1.sh, if the script receives SIGINT, how do I ignore the SIGINT in foo2.sh ? somehow foo2.sh does not finish to completion and is killed after receiving SIGINT. but foo1.sh is still executing. Is there any way to trap this signal in the child script. ? Please share your thots and inputs on this topic. Regards, Vikram S...

Writing Shell script to interactively control another shell script??
Using Solaris, Say you want to write a shell script to control another simple menu entry shell script like the following testscript.sh file /////////////////////// themenu() { echo "MENU" echo "1 - Check Status and other stuff " echo "2 - Run program" echo "3 - Exit" echo "" } while true do themenu read input case $input 1) //check status and do some other stuff ;; 2) //start program and other background processes;; 3) break;; //exit loop and program *) ;; done ////////////////////////////////////////////////////////////////// What I wan...

XEmacs shell-script-mode vs. Emacs shell-script-mode[bash]
I've noticed the shell-script-mode I get with Emacs behaves differently from that which I get with XEmacs. In particular the Emacs version provides a hard indentation feature (I don't know the formal term for hitting Tab to indent code to reflect the syntactic structure, but that's what I mean). Can I configure XEmacs (latest CVS) to support hard indentation when editing bash scripts? -- p->m == (*p).m == p[0].m >>>>> "Hattuari" == Hattuari <susudata@setidava.kushan.aa> writes: Hattuari> Can I configure XEmacs (latest CVS) to ...

expect script with shell script
I am using expect script in shell script. I want one value from expect script. how can i get the value from expect script and use it in shell script? On Thu, 4 Aug 2005, amitmjoshi@gmail.com wrote: > I am using expect script in shell script. > I want one value from expect script. > how can i get the value from expect script and use it in shell script? Have the expect script send the output to stdout (see [puts stdout ...]). In your shell script write: EXPECT_SCRIPT_RESULTS=`/path/to/your/expect/script.tcl` Michael In article <Pine.OSX.4.60.0508051853130.1253@powerbook.cleve...

Execute shell script from a perl script
Hi, How can I executed a Unix shell script from a Perl script. The shell script is a dump of a oracle table to a file. The perl script is for the reformat of this output file. Thanks Karel J. Gleixner wrote: > kderaedt wrote: > >> Hi, >> >> How can I executed a Unix shell script from a Perl script. >> The shell script is a dump of a oracle table to a file. The perl >> script is >> for the reformat of this output file. > > perldoc -f system > Or if your perl script takes input from STDIN, and you modified your shell script...

C-shell Script to Bash Script?
Dear Everyone: I used to use the following three lines of C-shell script foreach file (`ls -1 name.list.txt`) a.out $file end to do a loop. The 1st line lists the content in the file named "name.list.txt", and in the 2nd line, an excutable file, a.out, takes each listed item as an argument, and the 3rd line ends the loop. How would you convert the above three lines to BAsh (Bourne Again shell) script to be used on a Mac? Thank you for reading and replying! --Roland On 2007-08-01, qquito wrote: > Dear Everyone: > > I used to use the following th...