perl inside shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl inside shell script?
# 1  
Old 12-05-2010
perl inside shell script?

Hi UNIX Pros!

Newbie here, I would like to ask if it is possible to use perl commands inside a shell script? i created a simple script which connects to oracle and run queries which the script saves to a separate .txt file for each query issued. What i want to do is to create a presentable and well formatted excel file containing all the queries saved in the txt files. I saw from a post here in unix.com which points a link where it is possible to format excel via perl.

Thanks for reading! please do help me. cheers! Smilie
# 2  
Old 12-05-2010
why not try the perl command inside a shell script directly?
# 3  
Old 12-05-2010
yeah i'm trying, but it wont work. is there any startup code or whatsoever that i should do before i can start running perl commands? i specifically want to try Excel::Writer::XLSX for my script. Please help me!
# 4  
Old 12-05-2010
if you don't put your script, error message, how can we guess?
# 5  
Old 12-06-2010
Data

im trying to issue this command - use Excel::Writer::XLSX; an error message appears saying: "ksh: use: not found"

sorry for the noob questions
# 6  
Old 12-06-2010
You can use Perl inside a shell script, you just can't mangle it together as you please. This is an example of how to do it.
Code:
#!/usr/bin/ksh

echo "This is the shell script"

perl << 'EOF'
use strict;
use warnings;

my $var = "This is the Perl script\n";
print $var;
EOF

echo "This is the shell script again"

# 7  
Old 12-06-2010
so using "EOF" will do the trick?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

2. Shell Programming and Scripting

Perl inside shell

I am trying to find out the difference between two dates, for which I am using perl inside SHELL. Below are my codes. perl -MDate -e 'Date::Calc qw(Delta_DHMS);' perl -e '($Dd,$Dh,$Dm,$Ds) = Delta_DHMS($year1,$month1,$day1, $hour1,$min1,$sec1, $year2,$month2,$day2, $hour2,$min2,$sec2)' But... (6 Replies)
Discussion started by: sauravrout
6 Replies

3. Programming

Executing a awk command inside perl script --

Hello experts I want to execute a awk command, which reads from txt files and sums the numbers from the first column for those listed only inside a <init> block -- The awk command is like awk '/<\/?init>/{x = !x}x{a++}x && a > 2{sum+=$1}END{printf"%E" "\n", sum} So, I want to execute... (2 Replies)
Discussion started by: Alkass
2 Replies

4. Shell Programming and Scripting

Shell script inside a perl script

How to write a shell script inside a perl script code? It is possible or not. Actually i have a perl script code and i need some values from the shell script code and vice-versa i.e. some values of shell script use by the perl scipt and some values of perl script use by the shell script. So how can... (1 Reply)
Discussion started by: anupdas
1 Replies

5. Shell Programming and Scripting

how to run shell script inside expect script?

I have the code like this : shell script continues ... .... expect -c" spawn telnet $ip expect "login:" send \"$usrname\r\" expect "Password:" send \"$passwd\r\" expect "*\>" send \"$cmdstr\r\" ... (1 Reply)
Discussion started by: robbiezr
1 Replies

6. Shell Programming and Scripting

Call a perl script inside a shell script

Hi all, I have the following snippet of code.. #!/bin/sh echo "run perl script............" #Run the verification script perl bill_ver echo " perl script completed....." echo "rename files......" #Remove from all file in the directories test, test1, test2, test3 for f in... (3 Replies)
Discussion started by: chriss_58
3 Replies

7. Shell Programming and Scripting

invoking a shell script inside cgi shell script

Hi, I have an HTML form through which I get some text as input. i need to run a shell script say script.sh inside a perl-cgi script named main_cgi.sh on the form input. I want to write the contents of the form in a file and then perform some command line operations like grep, cat on the text... (2 Replies)
Discussion started by: smriti_shridhar
2 Replies

8. Shell Programming and Scripting

Run the command inside perl script

I have a command which will run fine in a unix command prompt. Can you tell how to interprete this command inside perl script...... The command is : perl -pe 's/(\|333\}.*)\}$/$1|1.6}/' FIA.txt This will search for the number 333 and appends 1.6 at the end of that line....... (1 Reply)
Discussion started by: vinay123
1 Replies

9. Shell Programming and Scripting

How to run unix commands in a new shell inside a shell script?

Hi , I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell. So scenario is that - I need to have one shell script which is ran as a part of crontab - in this shell script I need to do a... (2 Replies)
Discussion started by: hkapil
2 Replies

10. Shell Programming and Scripting

calling a C executable from inside a Perl script

here's the Perl code snippet... how can i call my C executable 'porter-stemmer' and pass it $1 as an argument? Thanks for the help! # Read through the original topic set, and modify based on the current # pre-processing options while (<TOPIC_ORIG>) { # Run pre-processing over only the... (3 Replies)
Discussion started by: mark_nsx
3 Replies
Login or Register to Ask a Question