Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2012
    Posts
    1

    Smile Unanswered: shell script question

    How do I call a ksh shell script within a main .ksh shell script?
    I have used the below and it does not work.

    main.ksh script has :
    ______________________________________________
    #!/bin/ksh
    cd /home/lib1/scripts
    vars.ksh
    funcs.ksh

    <calling the function here from funcs.ksh>

    export current_day='date'
    <some date processing code here>
    __________________________________________________
    The main.ksh script does not read the vars.ksh and funcs.ksh scripts and does not execute the functions called in the next line.
    I have tried to put the complete path as below and it does not work too.
    /home/lib1/scripts/vars.ksh
    /home/lib1/scripts/funcs.ksh


    Please help why it is not reading them. Also changed the permissions on ksh to 777.

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Unix and Linux, unlike DOS do not automatically include the current directory in the PATH,
    So:
    Either add the current directory to your path statement, or change the calling script to call the absolute script name.

  3. #3
    Join Date
    Oct 2011
    Posts
    3
    #!/bin/ksh
    HOME=/ home/lib1/scripts
    ${HOME}/vars.ksh
    ${HOME}/funcs.ksh

    <calling the function here from funcs.ksh>

    export current_day=`date`
    <some date processing code here>

    I hope this is one of the way to solve above issue.

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Actually you may also need to prefix the calling of the script with dot-space:
    Code:
    #!/bin/ksh
    HOME=/ home/lib1/scripts
    . ${HOME}/vars.ksh
    . ${HOME}/funcs.ksh
    
    <calling the function here from funcs.ksh>
    
    export current_day=`date`
    <some date processing code here>
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •