Invoke a bash script with perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Invoke a bash script with perl
# 1  
Old 09-20-2010
Bug Invoke a bash script with perl

Hi all,

I use the perl script to invoke the bash script. and now there is a problem.

my bash script lists as follows:
Quote:
JDK=`/usr/bin/java -version &>/tmp/jdk.txt; cat /tmp/jdk.txt|sed -n '1p'|awk -F\" '{print $2}'|awk -F_ '{print $1}'`
if [ "$SERVER_TYPE" = "i386" ]; then
if [ "$JDK" = "1.5.0" ]; then
info "The version of java installed on the server (i386) is 1.5."
else
error "The version of java installed on the server is not 1.5."
TEST_PASSED=FALSE
fi
else
if [ "$JDK" = "1.6.0" ]; then
info "The version of java installed on the server (sparc) is 1.6."
else
error "The version of java installed on the server is not 1.5."
TEST_PASSED=FALSE
fi
fi
and I use perl run this test scripts
Quote:
qx($command)
now the problem is when I run the perl script I find there is nothing recorded in the file /tmp/jdk.txt
# 2  
Old 09-20-2010
qx invokes a system call -one of the exec family - to create a child process.

1. The default shell for this is /bin/sh. Is /bin/sh the same as bash on your system?

2. qx returns output
Code:
@myarray = qx($command)

What output do you get?

You need to check for errors
If you have more problems tell us what you get from answering #1 & #2
# 3  
Old 09-20-2010
1. The /bin/sh is not same as the bash (/bin/bash)
2. I also use an array to store the outcome and the output is null
because I save the information of 'java -version ' into a file named jdk.txt and now I found the file is empty. So it can not get the java version from that file. Meanwhile the value of the $JDK is null and there is no additional error information
At the same time, I can run that bash script individually and work properly and the java version 1.5
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Using powershell on win10 to invoke bash

Hi Guys, I am trying to run flyway command on ubuntu. on windows command line is simple : C:\Users\admin\Downloads\flyway-commandline-5.0.7-windows-x64\flyway-5.0.7> flyway migrate how can i do it via bash? i tied to use mnt command but starting flyway is not possible. Please... (22 Replies)
Discussion started by: jaryszek
22 Replies

2. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

3. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

4. Shell Programming and Scripting

Calling a Perl script in a Bash script -Odd Situation

I am creating a startup script for an application. This application's startup script is in bash. It will also need to call a perl script (which I will not be able to modify) for the application environment prior to calling the application. The problem is that this perl script creates a new shell... (5 Replies)
Discussion started by: leepet01
5 Replies

5. Shell Programming and Scripting

Perl cgi script to call bash script?

Novice to perl here. I have created a simple web page in perl, with only one submit button. I would like to execute a bash script on the same server when this button is clicked on. Is this possible in perl? I have spent a few days researching this and am unable to find any useful information.... (0 Replies)
Discussion started by: pleonard
0 Replies

6. Shell Programming and Scripting

Invoke Perl function from Bash ?

Is it possible to invoke a perl function from a bash script ? There are existing perl scripts with many functions that I want to reuse from a more recent script written in bash. Hence the question. (1 Reply)
Discussion started by: NewDeb
1 Replies

7. Shell Programming and Scripting

Perl script to invoke Cold Backups

Hello, I am relatively new to Perl and I need help in creating a Perl script to automate a crontab job that starts and shutdowns multiple servers one server at a time. Script is to be run once a week. Below are the steps needed for the job... 1. Start stopping server1 and server2 using... (3 Replies)
Discussion started by: northern1969
3 Replies

8. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies

9. Shell Programming and Scripting

How to invoke a perl script from java program

Hi: I need to invoke a perl script from a java applet program in UNIX operating system.. Can you please suggest me!!! (4 Replies)
Discussion started by: grajesh_955
4 Replies

10. Shell Programming and Scripting

Invoke perl program from Ksh

Hi all, Can I invoke a perl script from Ksh script and pass parameters to the perl script. Please do help me.. thanks Maha (10 Replies)
Discussion started by: mahalakshmi
10 Replies
Login or Register to Ask a Question