🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
7 messages
7 total messages Started by Jody Zung Wed, 06 Dec 2000 00:00
Writing a script
#3817
Author: Jody Zung
Date: Wed, 06 Dec 2000 00:00
23 lines
1849 bytes
Hi folks. I'm new to writing shell scripts in unix so maybe someone
could help me out here.
I'm lookin to run some automated test cases. What I need to do is run a
process and output the results. Actually there is more I need to do but
I need to walk before I can run.

So basically it'll look like this.

I have a process called OMC that I run on a file. There are options as
well, so a command from the unix prompt would look like this:

omc  -dtmlckf -o <output dir> <filename.lib>

Then the thing runs for a while and ouputs a huge amount of stuff.
After this I want to check the output directory for the correct files.

So i'll cd to the output directory, do an ls, or ll and visually check
for the needed files.

Is there a way i can do all of this in a script and output to a results
file??

thanks in advance.
Re: Writing a script
#3818
Author: Nikolai Hristov
Date: Wed, 06 Dec 2000 00:00
20 lines
1170 bytes
Yes, there is a way, but you must read first:

tutorials:
http://www-4.ibm.com/software/developer/library/bash.html
http://www-4.ibm.com/software/developer/library/bash2.html
http://www-4.ibm.com/software/developer/library/bash3.html?dwzone=linuxml

reference:
http://www.gnu.org/manual/bash-2.02/bashref.html

If you still can't figure, I will help.

gl, Nick
------------------
Nikolai Hristov
Denison University
Granville OH 43023
hristo_n@denison.edu
hristo_n@linuxnexus.org
740-587-9272
Re: Writing a script
#3819
Author: Peter Roozemaal
Date: Wed, 06 Dec 2000 00:00
37 lines
2272 bytes
Jody Zung wrote:
> 
> So basically it'll look like this.
> 
> I have a process called OMC that I run on a file. There are options as
> well, so a command from the unix prompt would look like this:
> 
> omc  -dtmlckf -o <output dir> <filename.lib>
> 
> Then the thing runs for a while and ouputs a huge amount of stuff.
> After this I want to check the output directory for the correct files.
> 
> So i'll cd to the output directory, do an ls, or ll and visually check
> for the needed files.
> 
> Is there a way i can do all of this in a script and output to a results
> file??
> 
Yes, it's easy, but details depend on details of the application. It
looks like you're testing some batch application.

First: define testcases. (A testcase consists of an initialisation step,
followed by a sequence of program runs and validation of program
behavior: init, run, test, run, test,...)

Write a generic testcase driver that will perform
 1. the initialisation of the environment (depending on the testcase)
 in a loop
   2. run the application with the test inputfile
   3. check the correctness of the test output

You can use "i/o redirection" to collect output from your programs and
script in a file. For regressiontests it is convenient to have a set of
files with correct output so you can just run cmp or diff to check
whether anything has changed.

Peter.
Re: Writing a script
#3820
Author: Jody Zung
Date: Thu, 07 Dec 2000 00:00
48 lines
3034 bytes
Ok right, I do have this basic concept and understanding that you described
of how to do this but I suppose I need the specifics on doing it. Such as
what command outputs to a file.  I know i need to do some more homework and
read up on this but was hoping to find some quick easy answers.  Also if you
have experience using DejaGnu or Expect that would be great, its a test
automation tool but I don't understand how to use it and havn't found much
info on it.


Peter Roozemaal wrote:

> Jody Zung wrote:
> >
> > So basically it'll look like this.
> >
> > I have a process called OMC that I run on a file. There are options as
> > well, so a command from the unix prompt would look like this:
> >
> > omc  -dtmlckf -o <output dir> <filename.lib>
> >
> > Then the thing runs for a while and ouputs a huge amount of stuff.
> > After this I want to check the output directory for the correct files.
> >
> > So i'll cd to the output directory, do an ls, or ll and visually check
> > for the needed files.
> >
> > Is there a way i can do all of this in a script and output to a results
> > file??
> >
> Yes, it's easy, but details depend on details of the application. It
> looks like you're testing some batch application.
>
> First: define testcases. (A testcase consists of an initialisation step,
> followed by a sequence of program runs and validation of program
> behavior: init, run, test, run, test,...)
>
> Write a generic testcase driver that will perform
>  1. the initialisation of the environment (depending on the testcase)
>  in a loop
>    2. run the application with the test inputfile
>    3. check the correctness of the test output
>
> You can use "i/o redirection" to collect output from your programs and
> script in a file. For regressiontests it is convenient to have a set of
> files with correct output so you can just run cmp or diff to check
> whether anything has changed.
>
> Peter.
Re: Writing a script
#3821
Author: dongjinkim
Date: Fri, 08 Dec 2000 15:56
57 lines
2797 bytes
Hi Jody,

The basic things you need to know to get started is the following:

Parse the command line parameters:

$# = number of parameters passed to your program
$1 = parameter 1
$2 = parameter 3
etc...

You may have to surround variables and parameters in double quotes
if they contain more than one word.

Use the redirection symbol ">" to redirect the standard output from a
process to a new file.
Use the append symbol ">>" to append the standard output from a process
to an existing file.  (It will be created if it doesn't exist.)

That should help you get started...

Jin

In article <3A2E6922.61778861@siliconmetrics.com>,
  Jody Zung <jzung.zung@siliconmetrics.com> wrote:
> Hi folks. I'm new to writing shell scripts in unix so maybe someone
> could help me out here.
> I'm lookin to run some automated test cases. What I need to do is run
a
> process and output the results. Actually there is more I need to do
but
> I need to walk before I can run.
>
> So basically it'll look like this.
>
> I have a process called OMC that I run on a file. There are options as
> well, so a command from the unix prompt would look like this:
>
> omc  -dtmlckf -o <output dir> <filename.lib>
>
> Then the thing runs for a while and ouputs a huge amount of stuff.
> After this I want to check the output directory for the correct files.
>
> So i'll cd to the output directory, do an ls, or ll and visually check
> for the needed files.
>
> Is there a way i can do all of this in a script and output to a
results
> file??
>
> thanks in advance.
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.
Re: Writing a script
#3822
Author: Peter Roozemaal
Date: Fri, 08 Dec 2000 20:17
19 lines
2277 bytes
Jody Zung wrote:
> 
> Ok right, I do have this basic concept and understanding that you described
> of how to do this but I suppose I need the specifics on doing it. Such as
> what command outputs to a file.  I know i need to do some more homework and
> read up on this but was hoping to find some quick easy answers.  Also if you
> have experience using DejaGnu or Expect that would be great, its a test
> automation tool but I don't understand how to use it and havn't found much
> info on it.
> 
Do you have /some/ programming experience? Then you should start with
reading the manual pages for bash, ksh or sh (depending on which shell
is available). The command for that is "man sh". I/O redirection ia part
of the shell's job (and done with < and >).
cmp, diff and grep are great tools. Read their manpages too. And awk is
a simple and efficient programming language for making reports. (python,
perl and tcl are other commonly used scripting languages).

Peter
Re: Writing a script
#3816
Author: Griff Miller
Date: Wed, 13 Dec 2000 18:29
44 lines
2690 bytes
Jody Zung wrote:
> 
> Hi folks. I'm new to writing shell scripts in unix so maybe someone
> could help me out here.

I'm going to assume that you mean Bourne shell scripts.  (/bin/sh)

I recommend that you get a good book on the subject. Portable Shell
Programming by Blinn is my favorite.

> I'm lookin to run some automated test cases. What I need to do is run a
> process and output the results. Actually there is more I need to do but
> I need to walk before I can run.
> 
> So basically it'll look like this.
> 
> I have a process called OMC that I run on a file. There are options as
> well, so a command from the unix prompt would look like this:
> 
> omc  -dtmlckf -o <output dir> <filename.lib>
>
> Then the thing runs for a while and ouputs a huge amount of stuff.
> After this I want to check the output directory for the correct files.
> 
> So i'll cd to the output directory, do an ls, or ll and visually check
> for the needed files.
> 
> Is there a way i can do all of this in a script and output to a results
> file??
> 
> thanks in advance.

#!/bin/sh

omc  -dtmlckf -o /some/dir filename.lib >/tmp/savedoutput 2>&1
(cd /some/dir && ls -la) >>/tmp/savedoutput 2>&1

exit

-- 
Griff Miller II
Manager of Information Technology      "Beware of those who seek to win an
Positron Corporation                    argument at the expense of the
griff.miller@positron.com               language."  -Paul Johnson
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads