473,700 Members | 2,699 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling a Shell script from Perl

82 New Member
Hi, I have a shell script that I'm trying to call from perl.. What is the best way to go about this?

I'm looping through a file in perl, passing a variable to the shell script, doing some stuff in the shell script, then need to return to perl and move on to the next line.

Any advice would be appreciated..
Jul 25 '12 #1
2 1700
RonB
589 Recognized Expert Moderator Contributor
Does the Perl script need to capture any output from the shell script, or just execute it?

The system function or qx() operator is used to simply execute the script. If you need to capture the output, you'd use the ` ` backticks operator. There are other methods which can be used depending on your exact needs.

See: perldoc -f system
Jul 25 '12 #2
starlight849
82 New Member
It needs to simply execute it... Thanks for your response!!
Jul 27 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5663
by: Mohsin | last post by:
Hi all, I have a perl program which makes a user exit to the O/S (unix, solaris) to issue a O/S command. I know that the shell it invokes is NOT a korn shell, because I captured the shell info into a file with a 'ps' command. My question is "How to explicitly specify a Korn shell to be used by perl?" Eg of my perl code: ## Begin code snippet..
4
11221
by: nidhikhandelwal | last post by:
I am calling a unix shell script from a perl script by using the following system command: system("./readfile_new.sh"); but it seems the unix script readfile_new.sh is not being called. Can someone let me know how to call this script in the perl file/
2
6990
by: sunilsn | last post by:
Hi, I am newbie to perl, I hope you guys will help me resolve the challenge I am facing. I have a unix shell script on one UNIX machine say A, and a batch file on windows machine say B. Now I want to write a perl script on windows box which can trigger both, the batch file on B and the script on A Would you please help me...
7
22767
by: rajataggarwal | last post by:
Hi, I am learning perl to do some test automation. In my perl scripts I need to source shell script. Can someone tell me whats wrong with the code below. #!/usr/bin/perl system "source source.csh"; $rajat = $ENV{'RAJAT'};
0
906
by: rohitkec | last post by:
I have to run a shell script by perl script & intert some echo statements in the function calls of the shell script.I am new to both perl 7shell script ,please help........
1
2042
by: looza | last post by:
Hi All, I have a bunch of shell script files that use a common shell script file that contains certain global variables that are declared and initialized or derived by some arithmatic. I have to now convert one of the shell script file to a perl file so I can use the in-built functions. Is the a way I can import the file with the globals and use them in my perl script? Thanks!
7
6234
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke this shell script using the Subprocess module. Here is my code: def resultFromRunning_(command):
1
2930
by: karthigeyantp | last post by:
How to call a shell script from c++ program in linux
4
2600
by: kat248637 | last post by:
suppose i have a variable in shell script like a="prashant" and i want to assign this variable into another variable like b=$a,which is in perl script.after run perl script the value of b should be "prashant". thanks in advance
3
22382
by: littlemaster | last post by:
I have one configuration file. It will be used by perl and shell script. From perl using 'require' I have included the configuration file. Using require, include statement I tried in shell script , but it was not working. How to include a file and read value from that file using shell script?
0
8713
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8639
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9203
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7795
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4650
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2379
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2021
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.