chuhx
chuhx

Reputation: 334

Usage of linux system variable in the shebang

i try to include an external user folder with perl scripts to my general perl script. How can i use the linux system variable user (${USER}) to include these scripts? I tried to add this variable simply to the first line of the script, but the variable is not resolved.

Example:

#!/usr/bin/perl -I /tmp/userSpecificFolder-${USER}/anotherFolder/AndAnotherFolder/AndSoOn

And the Output of this line is exactly what i wrote above, but it should be

#!/usr/bin/perl -I /tmp/userSpecificFolder-CurrentUserName/anotherFolder/AndAnotherFolder/AndSoOn

Upvotes: 0

Views: 112

Answers (1)

Sobrique
Sobrique

Reputation: 53478

As you've discovered, the OS's parsing of the command line is very limited.

How about:

use lib "$ENV{'USER'}/anotherfolder/something/doodah";

You might also find FindBin useful, because it allows you to specify relative paths based on your script location.

e.g.

use FindBin;
use lib $FindBin::RealBin."/mods_dir";

Upvotes: 6

Related Questions