masb
masb

Reputation: 2843

Multiple java commands with script

all.

I have a quick question. I have a bunch of files named test01.vc, test02.vc, .., test84.vc. These are source code for a subset of c. Now I want to automatically test my compiler. So what I want to do is basically run three commands on each source file automatically. The commands are, in order:

java VC.vc testXX.vc
java jasmin.Main testXX.j
java testXX

How do I write a terminal script that does this for each file?

Upvotes: 1

Views: 74

Answers (2)

masb
masb

Reputation: 2843

I did something like this.

#!/bin/bash
# set n to 1
n=1

# continue until $n equals 5
while [ $n -le 84 ]
do
    java VC.vc testsFixed/test$n
    java jasmin.Main testsFixed/test$n.j
    java testsFixed/test$n
    n=$(( n+1 ))     # increments $n
done

Upvotes: 0

Origineil
Origineil

Reputation: 3118

Create a file with the following contents

for f in `find *.vc`; do

 fn=`echo $f | cut -d'.' -f1`;
 echo "Processing ... $f";

 java VC.vc $f
 java jasmin.Main $fn.j
 java $fn

done;

Place it in the same directory as the files you want to test. Run it as a bash script, invoking it by ./Filename after you have granted it run permissions (chmod +x Filename).

Upvotes: 1

Related Questions