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

  • Home
  • SEARCH
  • 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 7879801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:59:12+00:00 2026-06-03T03:59:12+00:00

I have written a program in linux bash and following are ways to start/stop

  • 0

I have written a program in linux bash and following are ways to start/stop that program:

start_program
stop_program
restart_program.

I have copied above scripts in /usr/bin so these scripts are working as command. but I want that instead of above commands I just type program name then pass action as parameter. for example if i want to start program then i should write on command prompt:

ProgramName start

if i want to uninstall then

ProgramName uninstall

if restart

ProgramName restart

so how can i make it that i just write Program name then pass action as parameter and Press enter to do that thing.

  • 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-06-03T03:59:14+00:00Added an answer on June 3, 2026 at 3:59 am

    A common approach is to use a case statement:

    case "$1" in
      start)
        # Your Start Code
        ;;
      stop)
        # Your Stop Code
        ;;
      restart)
        # Your Restart Code
        ;;
      *)
        echo "Usage: $0 {start|stop|restart}" >&2
        exit 1
        ;;
    esac
    

    If your restart is just stop then start, you can do:

    start() {
      # Your Start Code
    }
    
    stop() {
      # Your Stop Code
    }
    
    case "$1" in
      start)
        start
        ;;
      stop)
        stop
        ;;
      restart)
        stop
        start
        ;;
      *)
        echo "Usage: $0 {start|stop|restart}" >&2
        exit 1
        ;;
    esac
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a Linux system wide C++ program /usr/bin/PROG_X that uses a configuration
I have written a program that runs on Linux and uses sigevent and timer_create
I have a program written in C that runs on Linux, MacOS and Windows.
I have a program written in C++, on Linux, compiled with -g. When I
I have written a program that uses qhttp to get a webpage. This works
I have written a java program that is actually works as a gui to
I have written a small program and compiled it under Solaris/Linux platform to measure
I have a program written in C++, that opens a binary file(test.bin), reads it
Below is a program i have written that ran fine when I type what
I have a program written in C that has to input and output JSON

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.