Useful Commands


Using server in python enivronment

For using the shell commands from the python interface, you can use pexpect module in the python.

E.g.

> import pexpect

> import pxssh

> s = pxssh.pxssh()

> s.login('ra.ncra.tifr.res.in','rohit','rohit')

For netlify website publication, go to the folder and "netlify deploy".

Skip over an intermediate server

scp -r -oProxyCommand="ssh -W %h:%p rohit@wm.ncra.tifr.res.in" rohit@ra:/Data/rohit/large_size .

Copy recursively from one destination to other

find /media/kalenpw/MyBook/Music/ -name '*.mp3' -exec cp {} /media/kalenpw/HDD/Music \;

Find a string in the files in a folder

grep -rnw '/path/to/somewhere/' -e 'pattern'

To download a directory recursively, which rejects index.html* files and downloads without the hostname, parent directory and the whole directory structure

wget -r -nH --cut-dirs=2 --no-parent --reject="index.html*" http://mysite.com/dir1/dir2/data

Download MWA MS from server

wget 'https://asvo.mwatelescope.org:8778/api/download?job_id=142255&file_name=1100328928_ms.zip' -O 20141118_MWA.zip

Error while reading pickle

How to fix: "UnicodeDecodeError: 'ascii' codec can't decode byte"

FFMPEG Movie command

ffmpeg -framerate 8 -i velocity%d.jpeg -r 20 velocity.avi

Remove empty elements from the list

str_list=[x for x in str_list if x != '']

Installing SURYA into the python environment

python setup.py install

Linking directories

ln -s ~/my_git/lipi/surya ~/anaconda2/lib/python2.7/site-packages

ln -s main folder Destination to be linked

Install package inside CASA

CASA <2>: from setuptools.command import easy_install

CASA <3>: easy_install.main(['--user', 'pip'])

CASA <2>: import subprocess, sys

CASA <3>: subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--user', 'astropy'])

git commands

git init

git config --global user.name "rohitcbscient"

git config --global user.name "rohitcbscient@gmail.com"

--------------------------

Clone the repository

git remote add origin git@github.com:rohitcbscient/lipi.git

git remote set-url origin https://github.com/rohitcbscient/lipi.git

git pull origin master

For gitlab replace link with: gitlab.fhnw.ch/ip-61/dt_radio_telescope.git

--------------------------

git add filename

git status

git commit -m "comment"

git log

git reset filename

git reset HEAD filename

git checkout -- filename

#made .gitignore directory

git log --all --decorate --oneline --graph

alias graph='git log --all --decorate --oneline --graph'

git branch branch1

git branch branch2

git branch

git checkout branch1

git commit -a -m 'Both stage and commit with -a'

git merge branch1 # Merges to the current branch

git branch --merged

git branch -d branch1 # Delete branch

git checkout branch3

git checkout

git stash

get stash list

get stash apply

get stash apply

Procedure for the git sync between laptop and the server.

  1. Push the changes from the server
  2. Pull the changes in the laptop
  3. Resolve conflicts
  4. Push the change from the laptop
  5. Pull the change in the laptop. The server is now at a sync with laptop.

Install Sunpy full

  1. pip install sunpy[full]
  2. Or
  3. pip install sunpy[net]