Perl: Run perl script in the current process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl: Run perl script in the current process
# 8  
Old 12-08-2005
You would like the Perl script chdir() to affect the parent shell process? That is impossible in this case as exec() won't return, so when the Perl script ends, the original shell process also ends.

I'm sorry that I have probably misunderstood your question. I would say the method is only for the original process image (shell script in your case) affecting the later, replaced process image (the Perl script in your case), and doesn't work if you expect the parent environment to be influenced after exec(), as it won't return at all.
# 9  
Old 12-08-2005
So, as I understand, whatever the perl script does will not affect the parent shell.

Say, in this case, after I change to the new directory, I cant remain in that new directory even after the perl script exits. Right ?
# 10  
Old 12-09-2005
Absolutely correct. What you are asking: 'Can I source a file from inside perl?'
No. Because you have to call exec. This is exactly the same problem you have with shell scripts doing a cd and then exiting.
# 11  
Old 12-09-2005
Thanks Jim.

Vino
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. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

3. Shell Programming and Scripting

Perl system() to run a script

Hello, I'm trying to run "csso" (minify css) in a CGI script from the web panel. That is not working: Returns error 0; my $cmd = qq`csso stylesheet.css > stylesheet.min.css`; system($cmd); But that is working: my $cmd = qq`echo 'blabla' > stylesheet.min.css`; system($cmd); I'm... (12 Replies)
Discussion started by: madispuk
12 Replies

4. Shell Programming and Scripting

current date - 8 months in perl script

I have a requirement as follows. when i pass a date to the perl script, it has to calculate the current date - 8 months and output the date back to the shell script in date format (YYYY-MM-DD). Current date - 8 months is not constant.. because leap year, and the months jan, mar, may,.... has... (4 Replies)
Discussion started by: kmanivan82
4 Replies

5. Shell Programming and Scripting

run remote perl script

Hello i want create perl script to connect remotely to another machine and run perl script please note that the remote script check for different variables remotely and not located on local machine also i want to know how to send interactive variables i am trying to make script to... (2 Replies)
Discussion started by: mogabr
2 Replies

6. Shell Programming and Scripting

run sql query via perl script

Hello, If I run this command on the server it works. # dbc "update config set radio_enabled = 0;" how can I execute the same command in perl. I have defined the dbc path. Can any one please correct the last line. #!/usr/bin/perl #database path $dbc='/opt/bin/psql -Userver... (0 Replies)
Discussion started by: sureshcisco
0 Replies

7. 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

8. UNIX for Dummies Questions & Answers

Not able to run the simple perl script

Hi Experts, I have written simple perl script, which assign the value to variable and print it. Following is the script: $ cat 3.pl #!/usr/bin/env ksh #!/usr/bin/perl print "Hello World"; $iputlne = 34; print $iputlne; The error output is: $ /usr/bin/env perl 3.pl Hello World... (9 Replies)
Discussion started by: Amey Joshi
9 Replies

9. Shell Programming and Scripting

how to let the perl script to run for each file

Hi, I have more than 1 files in the directory. In bash, I can use cd /work for x in `ls` do : : done to run for each file in the directory. How about in perl script? filepath="ABC1" open(FILE, $filepath) or die "$filepath cannot be opened."; while(<FILE>) { : (1 Reply)
Discussion started by: natalie23
1 Replies

10. UNIX for Dummies Questions & Answers

cronjob to run perl script

Hi all Recently i had finished a perl script. When i run manually, the script work fine. But when i wanted to put the script in cron, it didn't get the same output as it run manually. I felt that it only execute the script until certain line then it stop as i see most of the related files didn't... (6 Replies)
Discussion started by: AirWalker83
6 Replies
Login or Register to Ask a Question