Thursday, May 2, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1167  / 1 Year ago, sun, april 23, 2023, 11:28:52

I made 2 .sh scripts to start and stop Xampp server. I'd like to merge them in a single launcher to obtain something like a ON/OFF button, so that if Xampp has already been started it would stop, but I don't know how to do that.



The code I have in my script is this:



#!/bin/bash

sudo /opt/lampp/lampp start;
echo "Starts Xampp server";


Can someone help me?



P.S. I read this answer but it doesn't help...why did Oli said "But I'll leave this up to you"? :P


More From » command-line

 Answers
3

I do not currently have a xampp server setup, BUT, it should be something like this :



 if [ $(ps aux | grep ###XAMPP PROCESS NAME### | wc -l) -gt 0;then
echo "Process is running, stopping"
###COMMAND TO STOP XAMPP###
else
echo "Process is not running, starting"
###COMMAND TO START XAMPP###
fi


like I said, I do not use xampp, so I'm not exactly sure what the process is called, or the commands to start and stop it, but this will work if you edit it with the process name and start/stop commands. The other guy had it right, just didn't simplify it with "command to stop/start"



EDIT : syntax error :)


[#32835] Monday, April 24, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
odyroc

Total Points: 324
Total Questions: 109
Total Answers: 103

Location: Belize
Member since Mon, Apr 17, 2023
1 Year ago
odyroc questions
;