Get Program That Satisfies the Condition

Beginner

In this project, you will learn how to create a script that can check if a program is running on a specified port and print the full path of the program or 'OK' if no program is running.

LinuxShell

Introduction

In this project, you will learn how to create a script that can check if a program is running on a specified port and print the full path of the program or "OK" if no program is running.

👀 Preview

## Example
$ cd /home/labex/project
$ sh get.sh 3000
/usr/lib/code-server/lib/node
$ sh get.sh 43000
OK

ðŸŽŊ Tasks

In this project, you will learn:

  • How to create a Zsh script
  • How to use the lsof command to check if a port is in use
  • How to use the ps command to get the full path of a running program

🏆 Achievements

After completing this project, you will be able to:

  • Write a script that can identify the program running on a specified port
  • Troubleshoot issues related to port conflicts in your development environment
  • Automate the process of checking for running programs on specific ports

Teacher

labby

Labby

Labby is the LabEx teacher.