Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 400919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:59:11+00:00 2026-05-12T16:59:11+00:00

i have unix shell script which is need to be run like below test_sh

  • 0

i have unix shell script which is need to be run like below

test_sh XYZ=KLMN

the content of the script is

#!/bin/ksh

echo $XYZ

for using the value of XYZ i have do set -k before i run the script.

is there a way where i can do this without doint set -k before running the script. or is there something that i can do in the script where i can use value of the parameter given while running the script in the below way

test_sh XYZ=KLMN

i am using ksh.
Any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:59:12+00:00Added an answer on May 12, 2026 at 4:59 pm

    It looks like you are trying to use the environment variable “INSTANCE” in your script.

    For that, the environment variable must be set in advance of executing your script. Using the “set” command sets exportable environment variables. Incidentally, my version of ksh dates from 1993 and the “-k” option was obsolete back then.

    To set an environment variable so that it is exported into spawned shells, simply use the “export” command like so:

    export INSTANCE='whatever you want to put here'
    

    If you want to use a positional parameter for your script — that is have the “KLMN” value accessed within your script, and assuming it is the first parameter, then you do the following in your script:

    #!/bin/ksh
    
    echo $1
    

    You can also assign the positional parameter to a local variable for later use in your script like so:

    #!/bin/ksh
    
    param_one=$1
    echo $param_one
    

    You can call this with:

    test_sh KLMN
    

    Note that the spacing in the assignment is important — do not use spaces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

who do i run/execute a unix shell(ksh) script which isaved on my Windows Xp
I have a unix shell script which test ftp ports of multiple hosts listed
I have the below line in the unix shell script. I want to exclude
I have a unix shell script which uses redirection of stdout and stderr to
I have an AWK script which looks like #!/usr/bin/gawk -f BEGIN { print myVar;
I have been trying to execute the following UNIX shell script which is not
I have a shell script (.sh) that works in Unix but I'd like to
I have a Unix shell script (bash) that sources some environment variables and then
I have a .sh unix shell script that receives as a parameter a path,
I have a Shell script which uses the date and time parameters entered by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.