perl_007 has asked for the wisdom of the Perl Monks concerning the following question:
I'm new to perl scripting and trying to source .bash_profile file and then do cd to the directory. below is the content of the .bash_profile file:
# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs export CTC_HOME=/Inf/work/ #PATH=$PATH:$HOME/.local/bin:$HOME/bin #export PATH
below is the script i'm trying to create:
#!/bin/perl # use strict; use warnings; if(-s "/cs/ctc/.bash_profile"){ `source ~/.bash_profile`; }else { print "The file doesnot exists","\n"; exit 1; } my $dir = "cd $CTC_HOME"; chdir($dir);
But, getting below error:
Any help is most welcome!!!Global symbol "$CTC_HOME" requires explicit package name at ./program. +pl line 12. Execution of ./program.pl aborted due to compilation errors.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: source a file in Linux using perl script
by Corion (Pope) on Nov 30, 2020 at 07:21 UTC | |
by salva (Canon) on Nov 30, 2020 at 09:23 UTC | |
by Corion (Pope) on Nov 30, 2020 at 09:50 UTC | |
Re: source a file in Linux using perl script
by Fletch (Chancellor) on Nov 30, 2020 at 14:48 UTC | |
Re: source a file in Linux using perl script
by LanX (Cardinal) on Nov 30, 2020 at 10:06 UTC | |
Re: source a file in Linux using perl script
by LanX (Cardinal) on Nov 30, 2020 at 12:00 UTC | |
Re: source a file in Linux using perl script
by perlfan (Vicar) on Nov 30, 2020 at 18:20 UTC |