workaround for sourcing file from perlscript 
Author Message
 workaround for sourcing file from perlscript

Hi all,

I  want to use  put this command in perl script
   source  abc
   executable argument

where abc is file which when sourced  sets some variable
and allow to use some executables
but if i put this in perl script and runs it. it source the file in new
shell and hence all those executables can't be run as they are run in
different shell .

Can any body tell the workaround

bye
ritesh

--
-----------------------------------------------------------------------
RITESH DIWAN                           Ph(O)-- 5099555
Group - Alit                           Ph(R)-- 5215583
H.no.3134   13th cross 6th C main
HAL IInd stage  Indranagar Bangalore INDIA
-----------------------------------------------------------------------



Mon, 06 Oct 2003 06:00:26 GMT  
 workaround for sourcing file from perlscript

Quote:

>I  want to use  put this command in perl script
>   source  abc
>   executable argument

>where abc is file which when sourced  sets some variable
>and allow to use some executables
>but if i put this in perl script and runs it.

Errr, _how_ are you running it? system() or backticks, I assume?
Got any Perl code showing how you run it?

Those methods use the Bourne shell, but "source" is a csh thingie.
sh isn't going to grok "source", it uses "." for that.

Quote:
>it source the file in new
>shell and hence all those executables can't be run as they are run in
>different shell .

Err, so run them in the _same_ shell then:

   !system ". abc; executable argument" or die "problem running system()";
                 ^
                 ^

:-)

Quote:
>Can any body tell the workaround

If you want to run csh, then run csh from the sh that system() gives you:

   !system "/bin/csh <some csh syntax here>" or die "problem running system()";

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Sun, 05 Oct 2003 22:41:29 GMT  
 workaround for sourcing file from perlscript

 > I  want to use  put this command in perl script
 >    source  abc
 >    executable argument
 >
 > where abc is file which when sourced  sets some variable
 > and allow to use some executables
 > but if i put this in perl script and runs it. it source the file in new
 > shell and hence all those executables can't be run as they are run in
 > different shell .
 >
 > Can any body tell the workaround

perldoc -q environment

Brandon



Sun, 05 Oct 2003 23:51:00 GMT  
 workaround for sourcing file from perlscript
You use system or backsticks it runs in the other shell and hence those
executables
are not visible from the shell as source has been done in other shell.

i have found one workaround but i would love know some thing better

what i have got is
put this source abc in shell script and  run perl programme from inside the shell
script this will source
the file abc as well as the perl script in one shell .

my shell script is as follows
#!/usr/bin/csh -f
source  abc
perl cfcore.pl $1 $2 $3

and executables are being called from perl programme cfcore.pl

Quote:


> >I  want to use  put this command in perl script
> >   source  abc
> >   executable argument

> >where abc is file which when sourced  sets some variable
> >and allow to use some executables
> >but if i put this in perl script and runs it.

> Errr, _how_ are you running it? system() or backticks, I assume?
> Got any Perl code showing how you run it?

> Those methods use the Bourne shell, but "source" is a csh thingie.
> sh isn't going to grok "source", it uses "." for that.

> >it source the file in new
> >shell and hence all those executables can't be run as they are run in
> >different shell .

> Err, so run them in the _same_ shell then:

>    !system ". abc; executable argument" or die "problem running system()";
>                  ^
>                  ^

> :-)

> >Can any body tell the workaround

> If you want to run csh, then run csh from the sh that system() gives you:

>    !system "/bin/csh <some csh syntax here>" or die "problem running system()";

> --
>     Tad McClellan                          SGML consulting

>     Fort Worth, Texas

--
-----------------------------------------------------------------------
RITESH DIWAN                           Ph(O)-- 5099555
Group - Alit                           Ph(R)-- 5215583
H.no.3134   13th cross 6th C main
HAL IInd stage  Indranagar Bangalore INDIA
-----------------------------------------------------------------------


Tue, 07 Oct 2003 09:33:51 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. sourcing (bash) config files within perl

2. Problems with sourcing a file

3. Problems with sourcing a file in perl.

4. Sourcing Unix environment file?

5. sourcing a file in Perl

6. sourcing (bash) config files within perl

7. Sourcing files from my perl script

8. Starting a perlscript in another perlscript

9. Starting a perlscript in another perlscript

10. perlscript .pl ------>> perlscript.EXE ....compilation

11. Writing to files Perlscript ASP NT Server

12. Random Access Files / Perlscript ASP

 

 
Powered by phpBB® Forum Software