473,396 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

IO redirection

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 1823
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 Expert Mod 4TB
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
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 Expert Mod 2GB
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 Expert 100+
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 Expert Mod 2GB
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
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...
52
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. ...
15
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...
2
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...
0
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"...
8
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...
13
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,...
1
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,...
4
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...
13
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...

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.