write script in cmd code example
Example 1: batch write file
REM # | NOTE: this is for batch files (windows cmd)
REM # | EXAMPLE
echo This is the text you want in the actual file > NewFile.txt
REM # | SYNTAX
REM # | echo [insert-text] > [file-name]
Example 2: make a command prompt with your own commands html
#kill-server
#!/bin/bash
RED='\e[31m'
NOCOLOR='\033[0m'
GREEN='\e[92m'
echo -e "Getting PID's from port :$1..."
PIDINFO=`netstat -ano | findstr :$1`
if [ $# -eq 0 ]
then
echo -e "${RED}No port number specified"
echo -e "${NOCOLOR}Usage: kill-server [port-number]"
exit 1
fi
# Convert to array
PIDINFOARR=($PIDINFO)
# Get the PID
PID=$(echo "${PIDINFOARR[4]}" | sed '')
# Kill the server
echo -e "Kill server :$1..."
if tskill "${PID}"; then
echo -e "${GREEN}Server port /:$1 with PID: ${PID} succesfully terminated."
else
echo -e "${RED}Server port /:$1 not succesfully terminated. It might be because server is not running."
exit 1
fi