Jump to content
Flubber

Simple BASH script for GNS3 (PID)

Recommended Posts

Posted (edited)

Script ce lanseaza GNS3 si printeaza PID-ul. Folositor pentru a scapa de obiceiul de a ii face call catre path-ul original (de exemplu daca a fost extras in /etc si path-ul pentru executie este: /etc/GNS3-0.8.3-src/./gns3) si nu preferati sa ii faceti alias (link symbolic nu functioneaza ;-) ).


#!/bin/bash

# This script fires up GNS3 and shows you the PID the instance is currently running under.
# This script is not intended for multiple instances.

# Path to your GNS3 executable (in this case it is supposed that GNS was extracted in /etc/)
path="/etc/GNS3-0.8.3-src/gns3"

if [ -e $path ]; then
echo -e "[$(tput setaf 1)$(tput bold)!$(tput sgr 0)] This script is intended for only one instance of GNS3!\n"
echo "[$(tput setaf 3)*$(tput sgr 0)] Your path to \"gns3\" is correct."
echo -n "[$(tput setaf 3)*$(tput sgr 0)] Firing up GNS3 ... "
$path &

sleep 1
echo -e "[ $(tput setaf 2)OK$(tput sgr 0) ]\n"

# Print PID - Ubuntu 12.04.1 LTS
# In case you have another distro change the '2p' in the last "sed" of the following line
# Check if it matches with the pid displayed in: `ps ax | grep gns3'
# <!> Usually '2p' is standard for start-up scripts written in this manner.
ppid=`ps ax | grep gns3 | sed -e "s/ \([0-9]*\).*/\1/" | sed -n '2p'`

echo -e "[$(tput setaf 2)+$(tput sgr 0)] Your GNS3 PID: $ppid\n"
exit 0
else
echo -e "[$(tput setaf 1)-$(tput sgr 0)] Check your path set to point at \"gns3\".\n"
exit 1
fi

Sau: http://sprunge.us/CaLj | http://sprunge.us/CaLj?bash - syntax highlighted

Get it:

echo -e -n "\n\n[$(tput setaf 3)*$(tput sgr 0)] Getting the script ... \n\n" ; wget http://sprunge.us/CaLj -O gns3.sh ; chmod +x gns3.sh ; sleep 1 ; echo -e "[ $(tput setaf 2)OK$(tput sgr 0) ]\n\n=================\nIf your GNS3 was extracted to a different place other than /etc/ then change it manually in the script (sorry! I was too lazy to match a way to find your gns3 so do it manually)\n=================\n\n[ $(tput setaf 2)DONE$(tput sgr 0) ] Script is ready. Also changed its mode to executable:\n" ; ls -l gns3.sh ; echo -e "\n"

Just for fun's sake.

Edited by Flubber

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...