Can you run a unix script from a perl program


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can you run a unix script from a perl program
# 1  
Old 08-23-2009
Can you run a unix script from a perl program

Hi all
i have a unix script reformatter.sh
i have a process whereby this script reformats a file before a perl program is used to update it
i am having a little problem automating the entire process . is there a way whereby i can call the unix script from the perl program ?
# 2  
Old 08-23-2009
Quote:
Originally Posted by dwightja24
...
is there a way whereby i can call the unix script from the perl program ?
Yes, you can use backticks (accent-graves) to run a Unix script/command etc. just like you do in the Bash shell. Or you can use the system command.

Check:

Code:
perldoc -f system

tyler_durden
# 3  
Old 08-23-2009
Just curious.

Are users dwightja and dwightja24 the same person?
# 4  
Old 08-23-2009
got confused with login names

yes i am


this is what i tried

the script takes two variables 1 input 2 output name

!/usr/bin/env perl

system("reformatnwc.sh CustomerData.txt tt.txt");

didnt work
# 5  
Old 08-23-2009
Quote:
Originally Posted by dwightja
...
didnt work
If you ask me, this is the vaguest answer you could give - "didn't work". It's like saying "I tried to reach office on time today. Didn't work."

Well ?
- Did you not get up on time ?
- Did you miss your bus ?
- Did your car not start ?
- Did you get stuck in traffic ?
- Did you get a flat tire ?
- Did you meet with an accident ?
- Did your tie get stuck in the sliding office door ?
As you can see, with a vague statement like that, the possibilities are endless.

And pertaining to your script:
- Do you know how to run a perl program ?
- Do you know what that first line means ?
- Do you know what should be put in that first line ?
- Did you invoke the program correctly ?
- Did your program fail miserably ?
- Did you get an error message ?
- Were you able to run the program successfully, but did not get the results you expected ?
- Does that script work properly when invoked on the terminal prompt ?
- Did you capture and examine the exit status in the perl program ?
- Did you read the documentation of the system function in perldoc (the command that was posted earlier) ?

Again, the possibilities are endless.
And without a crystal ball with us to gaze at, we are at loss to figure out what happened in your computer.

tyler_durden
# 6  
Old 08-23-2009
ksh: syntax error: `(' unexpected


all i had in the script is

!/usr/bin/env perl
#
system("reformatnwc.sh CustomerData.txt tt.txt");


tried running it from the propmt using . ./<program_name>
# 7  
Old 08-24-2009
Try replacing the first line with #!/usr/bin/perl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Perl program to run a Shell script issues...

Hi all, I have the following Perl script which is intended to run a Shell script and generate some logging for the purposes of tracking weather or not the script ran. I get an error, of course, since I don't know what I'm doing really. Here is the code: #!/opt/perl/bin/perl -w ... (14 Replies)
Discussion started by: zixzix01
14 Replies

3. Shell Programming and Scripting

count number of entries perl program or Unix script

Hi I have a file with number of entries name 1 123 name 1 345 name 1 65346 name2 3243 name2 24234 name 2 234234 so on ......... how to count total number of entries for name 1 and name2...and so on Please guide. (1 Reply)
Discussion started by: manigrover
1 Replies

4. Shell Programming and Scripting

Run perl script from Unix script

Hello Guys I have to run a perl script from unix one The reason for this is I have to connect to remote server and then execute the perl script. In unix script I am able to connect to remote server without any password via ssh ssh -o 'PasswordAuthentication yes' -o... (5 Replies)
Discussion started by: Pratik4891
5 Replies

5. Homework & Coursework Questions

Run Program from Bash CGI-Script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: This is a problem I am having with my 2 semester senior project. I have a LAMP server running Ubuntu 9.10 with... (8 Replies)
Discussion started by: JMooney5115
8 Replies

6. Shell Programming and Scripting

How to process and run a program in the background in perl?

Hi, I have a query about processing and running Perl program at the background. I have HTML file called Userform.html which accepts input from the user. As soon as input is given the contol goes to get.cgi (get.cgi does some processing and computing tasks). Actually get .cgi takes more... (0 Replies)
Discussion started by: vanitham
0 Replies

7. Shell Programming and Scripting

Run shell program in perl

Hello , I want to run some shell scripts in my perl script. I need to read the script's name from a file ( this file includes the name of all the scripts) and run the script one by one.. Please let me know how to go .. Thanks in advance, Radha (5 Replies)
Discussion started by: s123.radha
5 Replies

8. Shell Programming and Scripting

want to run different files under the same program using shell script

suppose have different files 1.1 2.2 3.3 4.4 5.5 All the files have to run under the same command say tr -d '\n' so how to run all the files under the same command by using shell script (3 Replies)
Discussion started by: cdfd123
3 Replies

9. UNIX for Dummies Questions & Answers

How do i run a program while in Unix?....

Im new and wanted to know if im in the unix terminal and lets say i want to run microsoft word for example. i go in and go into the HD and then keep going and i type ls and see that microsoft word.app is there. how do i run it from that? (4 Replies)
Discussion started by: Corrail
4 Replies

10. Shell Programming and Scripting

possible to run script to enter info within a program?

hi, I am new to Unix and script writing so I was wondering if this would be possible and how I might do it. I've learned to write a basic script and the first step I need to do is to open a program (for genetic linkage). The program then requires me to enter a lot of information. Sort of line... (1 Reply)
Discussion started by: lianderthal
1 Replies
Login or Register to Ask a Question