The special variable
$0
contains the name of the script being executed.
..or the link if you do that.
:-)
--lucy
<on 28.05.01, Tom Watson wrote>
> Firstly, HI to everyone - and thanks to the gurus for all the good advice
> for us beginners :)
>
> Now, the problem.
>
> I was working on a project and realized that if I created a simple shell
> program I could make things easier for myself. However, when I started to
> code I found myself with a dilemma:
>
> The program has to behave like two different programs depending on how it
> was called. i.e. it has to know what the instruction used to start it was -
> ignoring command-line parameters and such like. It would have two
> instructions for starting it, one the name of the program, the other a link
> to the same program but using a different name.
>
> For example, from the command-line I could run the program by typing
>
> [linux]# A -params OR
>
> [linux]# B -params
>
> I want to be able to know if the program was started using program name A
> or program name B. In pseudo-code:
>
> if (called by A){ do something ....}
> elsif (called by B){ do a something else ....}
>
> The program shares and stores the parameters for use with, (as it appears
> to the user), either A or B, but both parts of the program can access any
> of the parameters - they just act differently depending on the name used to
> start the program.
>
> I know that I could write two separate programs but the idea of doing it as
> one just seemed less untidy...... plus now I'm not going to be happy until
> I find an answer!
>
> I have searched, ok, glanced, you caught me ;), through the perldocs and
> the Perl Cookbook and found plenty dealing with capturing parameters passed
> to the program and system interaction, but none quite touching on the
> problem as I see it.
>
> One solution I was mulling over was to try and get access to the bash
> history (i.e. assume the last entry is our program being called) but the
> problem is I don't know where or how bash history is stored, nor when the
> last instruction is saved - i.e. if it is saved after the program executes
> its of no use to the program.
>
> Is there a simple way of doing this? Something like $^O (to get the os),
> for example?
>
> Thanks in advance for your help.
>
</>
--
Lucy Newman [EMAIL PROTECTED]