Operating System - Linux
1828779 Members
2950 Online
109985 Solutions
New Discussion

Re: Batch Job Submission Script

 
Blair Combs
Occasional Contributor

Batch Job Submission Script

Migrating from MPE to HP-UX.

We are relatively new to Unix and Unix scripting but are quickly gaining experience with posix and perl.

Need to convert batch jobs from Streamx (Vesoft).

Has anyone developed a good method for this?

Basically, Streamx prompts for variables that are then utilized within the batch job by way of code replacement just prior to launch.

Very basic example:

::echo Launching Example Job.
::read testvar?"Enter Variable ? "
!job testjob
!testcmd {testvar}
!eoj

** end of example **

:: commands are executed prior to launch.
! commands are executed post launch.
(note: some commands were changed to unix work-alike commands in example above.)

We have tested using Perl and Posix scripting with pros and cons for each.

We are considering developing a full application system to hopefully provide more functionality but this would be a more lengthy conversion.

Any ideas or suggestions would be appreciated.
10 REPLIES 10
Steven E. Protter
Exalted Contributor

Re: Batch Job Submission Script

Shalom Blair,

You might find expect scripting is useful to you.

http://hpux.connect.org.uk/hppd/hpux/Tcl/expect-5.43/

SEP
Help I keep posting when I should be asleep.
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: Batch Job Submission Script

Hi Blair:

In the absence of details, at first blush, either would suffice nicely.

If you are comfortable using perl, I would certainly consider building your job streams with it; *particularly* if you are considering developing a full applications system as you note.

The advantage gained, depending upon the complexity of your command parsing, would be that perl can handle matching, extracting and substituting pieces of parsed data in a more simple, elegant way than pure shell or shell blended with 'awk' or 'sed'.

Regards!

...JRF...
Muthukumar_5
Honored Contributor

Re: Batch Job Submission Script

You can automate the execution with buildin shell utilities like,

command <<-EOF
..
EOF

syntax. Or piping as,

(
echo "inputr"
sleep 1
echo "input"
sleep 1
) | command.

It is suitable to normal application. We can not use these tricks with secured things like ssh, su. We can use expect scripting in that stage. I hope you are requirement is falling with this 3rd of expect scripting.

--
Muthu
Easy to suggest when don't know about the problem!
Arunvijai_4
Honored Contributor

Re: Batch Job Submission Script

Hello,

As suggested, expect scripting will be the easiest of all. Perl is a very good, flexible scripting language in Unix and windows as well.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Blair Combs
Occasional Contributor

Re: Batch Job Submission Script

Thanks for the ideas provided.

I've been reading up on Expect and it appears to be a utility for automating responses to interactive prompts, among other things.

This is not my goal. I want the user to respond to all prompts. However, I want those responses to then be available to the batch job launched subsequent to the prompts.

Could I perhaps (reference basic example in the thread header):

1) grep the '::' lines into filea for execution as a normal posix shell script, after removing '::' from the front of each line.
2) editor-like line change commands could be added and echo'd to fileb after each interactive prompt and successful response.
(echo change '{var1}' to '$var1' all >>fileb )
3) grep all lines without '::' into filec.
4) run fileb against filec using editor making global changes to replace {vars} with the actual responses.
5) launch filec.

Does this make sense?

Blair
David Bellamy
Respected Contributor

Re: Batch Job Submission Script

Blair
#!/usr/bin/perl
use strict;
use diagnostics;

print "Enter response:";
my $response=;
system("batchjob $response");

hope this is what you are looking for
Arturo Galbiati
Esteemed Contributor

Re: Batch Job Submission Script

Hi,
basically you ahve to change from:
::echo Launching Example Job.
::read testvar?"Enter Variable ? "
!job testjob
!testcmd {testvar}
!eoj

to:
echo Launching Example Job.
read testvar?"Enter Variable ? "
noput testcmd testvar &

so I'd use:
sed 's/:://g;/!job/d;/!eoj/d;s/^!/nohup /;/nohup/ s/$/ \&/'

to obtain this.
HTH,
Art

Re: Batch Job Submission Script

Is it this you want:

#!/bin/sh
# scriptname: dojob1
echo "Launch Example"
read testvar?"Enter variable: "
export testvar
./dojob2


#!/bin/sh
# scriptname: dojob2
echo "In dojob2: $testvar"

Both scripts should be in the same directory.
If not, enter full path in stead of ./dojob2

Greetings,
Philippe
Blair Combs
Occasional Contributor

Re: Batch Job Submission Script

Thanks much for the ideas.

David, Is there something similar in Posix Shell?

Arturo, I am not familiar with the command 'noput'. We are using the posix shell.

Phillipe, I need all the source in one file and the program must run offline in batch. However, the process to submit the job could create temp files in order to successfully launch the program.

Thanks again and keep trying!
David Bellamy
Respected Contributor

Re: Batch Job Submission Script

echo "Enter Response:"
read x
batchjob($x)