# Wrapper Script in Perl Or shell

**URL:** <https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510>\
**Category:** Shell Programming and Scripting\
**Created:** [October 3, 2011, 4:11pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510 "2011-10-03T16:11:59Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![cotton](https://community.unix.com/letter_avatar/cotton/32/5_5575768a8748004e209b776fc1b2916d.png) [@cotton](https://community.unix.com/u/cotton)\
**Post date:** [October 3, 2011, 4:11pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/1 "2011-10-03T16:11:59Z")

</div>

Hello,

My requirement is based on Oracle where we run a perl script and it asked some questions.I want to write a wrapper which will answer all these questions.

How is it possible.

Thanks

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [October 3, 2011, 5:25pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/2 "2011-10-03T17:25:44Z")

</div>

You could try something like this:

```nohighlight
#!/bin/sh

/path/to/oracle/script.pl <<"EOF"
answer1
answer2
answer3
EOF

```

---

<div class="post-metadata">

**Author:** ![cotton](https://community.unix.com/letter_avatar/cotton/32/5_5575768a8748004e209b776fc1b2916d.png) [@cotton](https://community.unix.com/u/cotton)\
**Post date:** [October 3, 2011, 6:15pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/3 "2011-10-03T18:15:07Z")

</div>

> [@corona688](#):
>
> You could try something like this:
> 
> ```plaintext
> #!/bin/sh
> 
> /path/to/oracle/script.pl <<"EOF"
> answer1
> answer2
> answer3
> EOF
> 
> ```

This I have already tried and it does not work..

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [October 3, 2011, 6:16pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/4 "2011-10-03T18:16:32Z")

</div>

In what manner does it "not work". Be specific.

In fact, why not post the perl script?

---

<div class="post-metadata">

**Author:** ![cotton](https://community.unix.com/letter_avatar/cotton/32/5_5575768a8748004e209b776fc1b2916d.png) [@cotton](https://community.unix.com/u/cotton)\
**Post date:** [October 3, 2011, 6:19pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/5 "2011-10-03T18:19:02Z")

</div>

> [@corona688](#):
>
> In what manner does it "not work". Be specific.
> 
> In fact, why not post the perl script?

Basically the answers are passed in the successive manner in 1 go..and the paramter keep telling null has been received...

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [October 3, 2011, 6:23pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/6 "2011-10-03T18:23:16Z")

</div>

Please post the perl script so we can see what form of input it needs. If it's simply reading from stdin, that ought to work. 😕

---

<div class="post-metadata">

**Author:** ![cotton](https://community.unix.com/letter_avatar/cotton/32/5_5575768a8748004e209b776fc1b2916d.png) [@cotton](https://community.unix.com/u/cotton)\
**Post date:** [October 3, 2011, 6:23pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/7 "2011-10-03T18:23:20Z")

</div>

#!/bin/sh

/mnt/oracle/oracle/product/11.2.0/dbhome\_2/appsutil/bin/adbldxml.pl \<\<EOF  
apps  
aa  
rr  
qq  
EOF  
[oracle@wkdevpr12rac1 bin]$

OUTPUT

Starting context file generation for db tier..  
Using JVM from /mnt/oracle/oracle/product/11.2.0/dbhome\_2/appsutil/jre/bin/java to execute java programs..

/mnt/oracle/oracle/product/11.2.0/dbhome\_2/appsutil/jre/bin/java -classpath /mnt/oracle/oracle/product/11.2.0/dbhome\_2/jdbc/lib/ojdbc5.jar:/mnt/oracle/oracle/product/11.2.0/dbhome\_2/appsutil/java:/mnt/oracle/oracle/product/11.2.0/dbhome\_2/appsutil/java/xmlparserv2.jar:/mnt/oracle/oracle/product/11.2.0/dbhome\_2/jlib/netcfg.jar:/mnt/oracle/oracle/product/11.2.0/dbhome\_2/jlib/ldapjclnt11.jar

-user apps  
APPS Password:  
The log file for this adbldxml session is located at:  
/mnt/oracle/oracle/product/11.2.0/dbhome\_2/appsutil/log/adbldxml\_10031722.log  
AC-20010: Error: File - listener.ora could not be found at the location:  
/listener.ora  
indicated by TNS\_ADMIN. Context file can not be generated.

Could not Connect to the Database with the above parameters, Please answer the Questions below

Enter Hostname of Database server:  
Enter Valid Input

Enter Hostname of Database server:  
Enter Valid Input

Enter Hostname of Database server:  
Enter Valid Input

It should have passed aa

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [October 3, 2011, 6:25pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/8 "2011-10-03T18:25:31Z")

</div>

```nohighlight
APPS Password:

```

I bet this is being read from /dev/tty, not not stdin.

As for the rest, I still cannot say, because you still haven't posted the perl script, please post the perl script.

---

<div class="post-metadata">

**Author:** ![cotton](https://community.unix.com/letter_avatar/cotton/32/5_5575768a8748004e209b776fc1b2916d.png) [@cotton](https://community.unix.com/u/cotton)\
**Post date:** [October 3, 2011, 6:29pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/9 "2011-10-03T18:29:01Z")

</div>

> [@corona688](#):
>
> ```plaintext
> APPS Password:
> 
> ```
> 
> I bet this is being read from /dev/tty, not not stdin.
> 
> As for the rest, I still cannot say, because you still haven't posted the perl script, please post the perl script.

okay..attached is the same...

---

<div class="post-metadata">

**Author:** ![cotton](https://community.unix.com/letter_avatar/cotton/32/5_5575768a8748004e209b776fc1b2916d.png) [@cotton](https://community.unix.com/u/cotton)\
**Post date:** [October 3, 2011, 6:30pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/10 "2011-10-03T18:30:29Z")

</div>

Attachment...

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [October 3, 2011, 6:35pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/12 "2011-10-03T18:35:13Z")

</div>

Thanks. The script accepts arguments like `/mnt/oracle/oracle/product/11.2.0/dbhome_2/appsutil/bin/adbldxml.pl appsuser=username appspass=pass template=templatename logfile=filename outfile=outfilename servername=server jtop=stuff`

If you want it to ask, you can do a shell script like

```nohighlight
#!/bin/sh
printf "username: "
read DBUSER

...

/mnt/oracle/oracle/product/11.2.0/dbhome_2/appsutil/bin/adbldxml.pl appsuser="$DBUSER"

```

---

<div class="post-metadata">

**Author:** ![cotton](https://community.unix.com/letter_avatar/cotton/32/5_5575768a8748004e209b776fc1b2916d.png) [@cotton](https://community.unix.com/u/cotton)\
**Post date:** [October 4, 2011, 9:34am UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/13 "2011-10-04T09:34:39Z")

</div>

> [@corona688](#):
>
> Thanks. The script accepts arguments like `/mnt/oracle/oracle/product/11.2.0/dbhome_2/appsutil/bin/adbldxml.pl appsuser=username appspass=pass template=templatename logfile=filename outfile=outfilename servername=server jtop=stuff`
> 
> If you want it to ask, you can do a shell script like
> 
> ```plaintext
> #!/bin/sh
> printf "username: "
> read DBUSER
> 
> ...
> 
> /mnt/oracle/oracle/product/11.2.0/dbhome_2/appsutil/bin/adbldxml.pl appsuser="$DBUSER"
> 
> ```

no this wont work..because the parameters are not in the perl script..if you see the main program..it calls the java..where alll this is defined...

---------- Post updated at 08:34 AM ---------- Previous update was at 08:33 AM ----------

Do we have any other way...I am yet to find a workable solution..  
Thanks

---

<div class="post-metadata">

**Author:** ![durden\_tyler](https://community.unix.com/user_avatar/community.unix.com/durden_tyler/32/1450_2.png) [@durden\_tyler](https://community.unix.com/u/durden_tyler)\
**Post date:** [October 4, 2011, 10:54am UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/14 "2011-10-04T10:54:51Z")

</div>

> [@cotton](#):
>
> ...  
> Could not Connect to the Database with the above parameters, Please answer the Questions below
> 
> Enter Hostname of Database server:  
> Enter Valid Input
> 
> Enter Hostname of Database server:  
> Enter Valid Input
> 
> Enter Hostname of Database server:  
> Enter Valid Input  
> ...

Where does the Perl program ask for the input as seen above?

tyler\_durden

---

<div class="post-metadata">

**Author:** ![cotton](https://community.unix.com/letter_avatar/cotton/32/5_5575768a8748004e209b776fc1b2916d.png) [@cotton](https://community.unix.com/u/cotton)\
**Post date:** [October 4, 2011, 12:20pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/15 "2011-10-04T12:20:36Z")

</div>

> [@durden\_tyler](#):
>
> Where does the Perl program ask for the input as seen above?
> 
> tyler\_durden

When we call the perl script it will call a java program and there it will ask you 3 questions...  
Enter HostName  
Enter Port  
Enter SID

I need to provide the same using a wrapper perl script..or any other way it can be done...

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [October 4, 2011, 12:45pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/16 "2011-10-04T12:45:17Z")

</div>

It definitely feeds those options into java:

```nohighlight
my $optionString = getOptions();
    my $err = runSystemCmd("$javaCmd "."oracle.apps.ad.context.GenerateContext ". "$optionString");

```

Try adding the line

```nohighlight
print STDERR $optionString, "\n";

```

above runSystemCmd so you can see what it's actually feeding into java. That will help you get it 'just right'.

---

<div class="post-metadata">

**Author:** ![cotton](https://community.unix.com/letter_avatar/cotton/32/5_5575768a8748004e209b776fc1b2916d.png) [@cotton](https://community.unix.com/u/cotton)\
**Post date:** [October 5, 2011, 8:30pm UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/17 "2011-10-05T20:30:00Z")

</div>

> [@corona688](#):
>
> It definitely feeds those options into java:
> 
> ```plaintext
> my $optionString = getOptions();
> my $err = runSystemCmd("$javaCmd "."oracle.apps.ad.context.GenerateContext ". "$optionString");
> 
> ```
> 
> Try adding the line
> 
> ```plaintext
> print STDERR $optionString, "\n";
> 
> ```
> 
> above runSystemCmd so you can see what it's actually feeding into java. That will help you get it 'just right'.

I have all the tried and nothing works..i need to read the screen ouptut and then input based on the same...

Thanks

---

<div class="post-metadata">

**Author:** ![durden\_tyler](https://community.unix.com/user_avatar/community.unix.com/durden_tyler/32/1450_2.png) [@durden\_tyler](https://community.unix.com/u/durden_tyler)\
**Post date:** [October 6, 2011, 1:58am UTC](https://community.unix.com/t/wrapper-script-in-perl-or-shell/296510/18 "2011-10-06T01:58:15Z")

</div>

> [@cotton](#):
>
> I have all the tried and nothing works..i need to read the screen ouptut and then input based on the same...

What does that Java program look like?

tyler\_durden
