473,569 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IO redirection

7 New Member
Im trying to execute a perl script from a shell script. I have to pass the path of a file in the command line when i execute the perl script (Automate the perl script execution). How do i feed the path to the perl script through the shell script?

Details of the perl script execution:

$perl sample.pl
Enter the filename:

Details of the unsuccessful shell script:
#!bin/sh
/usr/bin/perl /home/name/sample.pl<< "<pathname"

I dont want to hardcode the path. But i tried passing the path of the file using << in the shell. It didnt work. Please help me.
Dec 20 '07 #1
6 1828
thelevitator
7 New Member
Ppl,

please help me fix this problem. Its kind of urgent..I sat on it for more than 2 days. But im totally lost. Its a pretty dumb problem actually.

Im trying to run a crontask on a remote system. I should execute a shell script at a given time.

For ex: * * * * * bash /Users/name/sample.sh

In the script ive included commands to perform database backup. It works fine. But the problem is that, ive to run a perl script prior to the execute of mysqldump. For some dumb reason, it wouldnt execute.
Details of the file sample.sh:

/usr/bin/perl /Users/name/chumma.pl

If i run this command it should update some tables in my local database. Then i should run mysqldump to import it to a remote database, which works fine.

I dont know why the crontask wouldnt execute. I dont know if there is a problem with the shell syntax or the perl syntax.

Please not that, i SSH into a remote system to run the cronjob..
thelevitator is online now Report Post Edit/Delete Message
Dec 20 '07 #2
sicarie
4,677 Recognized Expert Moderator Specialist
Okay a few things:
Does the perl script run without being in the cronjob? What happens if you cd to /Users/name/ and do a './chumma.pl' ? Also, If you are running a cronjob, you should nto have to remote in to execute this. FYI your example cronjob is not set to run at a specific time. I don't know if that means is runs constantly, or never, but my guess would be never.
Dec 20 '07 #3
thelevitator
7 New Member
Hi,

I couldnt get the script to run by giving ./chumma.pl, it executes if i'd give perl chumma.pl. I didnt give the specific time. Please ignore that part. I just want the crontask to execute. So as of now, im just testing it for the next minute.

If i'd try executing using ./chumma.pl it throws the bash error permission denied.

Does it have anything to do with setting the permissions? Is that why it is not executing? But i tried to execute mysqldump command and it does work. Any suggestions??
Dec 20 '07 #4
numberwhun
3,509 Recognized Expert Moderator Specialist
Hi,

I couldnt get the script to run by giving ./chumma.pl, it executes if i'd give perl chumma.pl. I didnt give the specific time. Please ignore that part. I just want the crontask to execute. So as of now, im just testing it for the next minute.

If i'd try executing using ./chumma.pl it throws the bash error permission denied.

Does it have anything to do with setting the permissions? Is that why it is not executing? But i tried to execute mysqldump command and it does work. Any suggestions??
Since you are on a Unix system, and the script won't run when you just give "./chumma.pl", then you need to edit it and ensure that the first line reads:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
The shebang line needs to be the first line in the script and should contain the above (with your path to the perl interpreter of course).


Either way, if you run that shell script (that runs the Perl script), does the Perl script run? If it doesn't then you have an issue there that needs to be resolved before Cron can do its job.

Regards,

Jeff
Dec 21 '07 #5
arne
315 Recognized Expert Contributor
Im trying to execute a perl script from a shell script. I have to pass the path of a file in the command line when i execute the perl script (Automate the perl script execution). How do i feed the path to the perl script through the shell script?

Details of the perl script execution:

$perl sample.pl
Enter the filename:

Details of the unsuccessful shell script:
#!bin/sh
/usr/bin/perl /home/name/sample.pl<< "<pathname"

I dont want to hardcode the path. But i tried passing the path of the file using << in the shell. It didnt work. Please help me.

If you do not have control over sample.pl yopu could try

Expand|Select|Wrap|Line Numbers
  1. echo "pathname" | /usr/bin/perl /home/name/sample.pl
  2.  
If you have written sample.pl yourself, make the
pathname you want to pass a parameter, so that
you can use

Expand|Select|Wrap|Line Numbers
  1. /usr/bin/perl /home/name/sample.pl pathname
  2.  
in your shell script. For this the sample.pl script
should use the @ARGV array instead of reading
from STDIN.

HTH,
arne
Dec 22 '07 #6
numberwhun
3,509 Recognized Expert Moderator Specialist
This is the SAME question that you asked in your other thread, which still needs an answer(s) from you from my last post to your thread.

I am merging the two threads as we don't need two of the same questions floating around out here.

Regards,

Jeff
Dec 22 '07 #7

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

Similar topics

2
5787
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues to execute the code until the browser send his reply to the header instruction. So an exit(); after each redirection won't hurt at all
52
5409
by: Gerard M Foley | last post by:
Can one write a webpage which is not displayed but which simply redirects the user to another page without any action by the user? Sorry if this is simple, but I am sometimes simple myself. Happy New Year -- Gerry
15
5130
by: Taki Jeden | last post by:
Hello everybody Does anybody know why w3c validator can not get pages that use 404 htaccess redirection? I set up two web sites so that clients request non-existent urls, but htaccess redirects calls to a script which parses the url and produces requested pages. It works fine with browsers, but when I try to validate the page I get a 404...
2
3587
by: Nadav | last post by:
Hi, Introduction: *************** I am trying to redirect stdout to a RichEdit control, this is done by initiating a StringWriter, associated it with a StringBuilder and setting the Console.Out to the String Writer, when ever the RichEdit is to be updated text from the StringBuilder is being copied. The Problem:
0
1478
by: Dimitrios Mpougas | last post by:
Hello, I have two asp.net pages. The first is a page (main.aspx) wich has four links on it. The href value of each link is: href="view.aspx?id=1" traget="_blank" href="view.aspx?id=2" traget="_blank" href="view.aspx?id=3" traget="_blank" href="view.aspx?id=4" traget="_blank"
8
2521
by: Luciano A. Ferrer | last post by:
Hi! I was following the http://www.seomoz.org/articles/301-redirects.php article, trying to do that with one of my test sites I added this to the .htaccess file: RewriteEngine On RewriteCond %{HTTP_HOST} !^domain\.com.ar RewriteRule ^/(.*) http://domain.com.ar/$1
13
2687
by: souissipro | last post by:
Hi, I have written a C program that does some of the functionalities mentionned in my previous topic posted some days ago. This shell should: 1- execute input commands from standard input, and also from a file conatining the commands 2- does the redirection of the input and output from and to files. 3- retrieve the environment variables...
1
3517
by: comp.lang.php | last post by:
require_once("/users/ppowell/web/php_global_vars.php"); if ($_GET) { // INITIALIZE VARS $fileID = @fopen("$userPath/xml/redirect.xml", 'r'); $stuff = @fread($fileID, @filesize("$userPath/xml/redirect.xml")); @fclose($fileID); // XML PARSE
4
1820
by: psual | last post by:
hi newbie in web design I got some issue concerning a secure redirection between 2 pages let say I have a page with a grid (the 'master' page) in this grid I can select a record, get its pk then I redirect to another page (the 'detail' page) with the pk as parameter
13
4323
by: Massimo Fabbri | last post by:
Maybe it's a little OT, but I'll give it try anyway.... I was asked to maintain and further develop an already existing small company's web site. I know the golden rule of "eternal" URIs, but in this case changing them cannot be avoided as they were badly chosen when thwe site was first delevoped: URLs with spaces, typos, etc. So I have...
0
7695
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...
0
7922
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. ...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6281
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...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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
0
936
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...

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.