Monday 26 November 2018

Clone a repository with all branch using Bash Script

This bash script will cone a repository with all branch.

Create a new file git_clonerepo.sh and Put the below bash script in that file and make executable using chmod +x git_clonerepo.sh and run it

$ vim git_clonerepo.sh

#!/bin/bash
function repoclone {

        echo -n "Enter the Git repository URL : "
        read  url
        reponame=$(echo $url | awk -F/ '{print $NF}' | sed -e 's/.git$//')
        git clone $url
        cd $reponame
        for branch in $(git branch -a | grep '^\s*remotes' | egrep --invert-match '(:?HEAD|master)$'); do
            git branch --track "${branch##*/}" "$branch"
        done

}

repoclone



$ chmod +x git_clonerepo.sh

$ ./git_clonerepo.sh

Sunday 18 November 2018

Share files and directories using Python SimpleHTTPServer


SimpleHTTPServer module that comes with Python. It provides standard GET and HEAD functions.

It can be used to set up a very basic web server serving files relative to the current directory. You can use this to turn any directory in your system.

Advantage with the built-in HTTP server is that you don't have to install and configure anything. The only thing that you need, is to have Python installed.

To start a HTTP server on port 8888

manivel@manivel ~/webserver $  python -m SimpleHTTPServer 8888
Serving HTTP on 0.0.0.0 port 8888 ...

       -m     ---> module-name
       8888 ---> port  (You can also change the port to something else)

This will now show the files and directories which are in the current working
directory.

Open your favorite browser and type in any of the following addresses:

http://localhost:8888  or  http://127.0.0.1:8888   or   http://ipaddress:8888



If you don't have an index.html file in the directory, then all files and directories will be listed.