Using custom script inside .profile file in ksh

569 views Asked by At

I am trying to use a script that takes in some parameters inside my .profile file. The script is basically to execute a particular operation(from a set) on a list of jobs. So I execute the script like this.

sh bulkCommandProcessor.sh commandName job1 job2 job3...

Since the number of commands that can go in as the first argument is only 7, I would like to have aliases for each of it in my .profile file. I tried the following.

alias bjr='sh /home/vijay/scripts/bulkCommandProcessor.sh jr'

However, this doesnt seem to work. The error handling part of my code gets displayed when I source the .profile file which says something like this.

usage: /home/vijay/scripts/bulkCommandProcessor.sh cmd Job_name1 Job_name2 Job_name3 ..

Is there a way to achieve what I intend? That is use a script that accepts variable length of arguments within the .profile file.

1

There are 1 answers

0
nay743 On

First I think you need to make sure that your script bulkCommandProcesor.sh has the right permissions, that it is in the right path and that your are correctly parsing arguments for your script. I think that the following template might work:

    #!/usr/bin/ksh
    # .profile example


    alias bjr='sh /home/vijay/scripts/bulkCommandProcessor.sh jr'

    #variable length arguments in jobs 
    #where you previously get job1,job2 for example

    jobs="$job1 $job2"

    #And finally calling your script
    bjr $jobs