[LUNI] shell scripting question...

Constantin Gavrilescu costi at apluscompuservices.com
Sun Apr 5 12:13:38 CDT 2009


make a test.sh file with this content:

#!/bin/bash
echo $0

do a chmod +x test.sh
Run it with ./test.sh
It outputs "./test.sh".

Now make a symbolic link to that file:
ln -s test.sh script.sh

Run the symbolic link. It will output "./script.sh".

Now you know that a which symlink is calling the program. You can go from
there to:

 ln -s test.sh "test param1 param2 param3.sh"

You created a symbolic link with params. Change test.sh to:

#!/bin/bash
PROGRAM_NAME=$0
echo first parameter is : `echo ${PROGRAM_NAME} | awk '{print $2}'`
echo second parameter is : `echo ${PROGRAM_NAME} | awk '{print $3}'`

Now you are passing parameters through symbolic links.


On Fri, Apr 3, 2009 at 3:50 PM, Andrew Close <aclose at gmail.com> wrote:

> hi all,
>
> i'm attempting to create a generic startup script for a couple
> WebLogic domains we have on a development box here at work.  in the
> past i had a script that i used for a single domain.  instead of
> maintaining three scripts, i figured i'd just have soft links to the
> single script and pass in any needed parameters.  is there a way to
> make a specific link automatically pass a parameter?
> for example, my startup script is located in /opt/scripts and one link
> would be in /opt/bea/.../MyDomain.  when i call `script.sh
> startServer` i'd also like the domain path (pwd) and domain port
> passed in as args, but i'd prefer the users didn't have to remember or
> type them in.
> the only other analogy i have is shortcuts in windows.  you can create
> a shortcut to an application and then add arguments to it
> that are used by the application you're linking to.
> any thoughts?  or am i going about this in a non-*nix way?  :)
>
> --
> Andrew Close
> --
> Linux Users Of Northern Illinois (Chicago) - Technical Discussion
> http://luni.org/mailman/listinfo/luni
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://luni.org/pipermail/luni/attachments/20090405/c66d3147/attachment.html 


More information about the LUNI mailing list