Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get/Execute bash shell alias

Status
Not open for further replies.

CJason

Programmer
Oct 13, 2004
223
US
I have an alias set in my bash shell, say:

THISALIAS='this.exe'

In my perl script, I want to execute this alias...something like:
Code:
system("THISALIAS");
Any ideas on how I can access the alias in order to execute it?? Thanks in advance!
 
Do u now the alias fullpath, if yes you could just use it like

Code:
my $alias = "/fullpath/this.exe";
system($alias);

if you don't know the alias full path, decription, you could check it via perl script and then use the value of it within system

Code:
my $alias= `echo $THISALIAS`; 
# check the command in your unix system, syntax may vary
system($alias);









dmazzini
GSM/UMTS System and Telecomm Consultant

 
I have found to NEVER rely on alias and path variables that come from things like .profile/.login, that are not always available via crons and such. I prefer just to set everything myself in my scripts.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
dmazzini, unfortunately, alias variables don't show up with `echo $THISALIAS`...an alias is not an environmental variable. From a bash shell, you would get the alias by: "alias THISALIAS"...but, I can't seem to see an alias variable within a perl script.

travs69, fortunately, I have the ability to make these aliases environmental variables. However, I wanted to see if I could save a little work by accessing the "already there" alias variables.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top