#!/usr/bin/perl -w # shellGet.pl # A program to return the current shell of the user # # Christopher Dykes (2008-09-30) #Use the following modules: use strict; #Use strict syntax use warnings; #Enable warnings #Get the environment data write it externally and open it for use: system("env > .env.txt"); open(ENV, ".env.txt") || die("Couldn't open environment data file: $!"); while(my $fileLine = ) #Read in our environment file { if($fileLine =~ /SHELL=/) #Search for the shell line { my @shellLine = split(/=/, $fileLine); #Extract the relevant portion print "$shellLine[1]"; #Display our shell #All done: close ENV; #Close the environment file system("rm .env.txt > /dev/null"); #Clean up the environment file exit; #And Quit } } #We shouldn't get here unless there's been an error: die("\aError: Couldn't find SHELL\texiting\n");