Tips Linux

Linux, DevOps and Security

Category: Uncategorized

Elegant way to pass arguments to a bash script

 

When I started to write bash scripts, I found that it was really convenient to use the basic way to pass arguments with $1 $2 and so on.

Continue reading

Simple python random

Recently, I had to chose randomly 4 people for a thankless task. It was the perfect occasion to code a simple script using the Python random module:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#export PYTHONIOENCODING=utf8
import random
people_initials = ['ML','WD','ME','BH','FS','AQ','SB','FR','KB','LL','FP','MG','AH','FJ']
rand_people = random.sample(people_initials, 4)
print rand_people

 

Don’t name your script random.py or it won’t work.

How to resume a stalled scp transfer

SCP is the perfect command line tool to transfer huge files from a server to another one but if the connection drops, the transfer become “stalled” and seems impossible to resume. Don’t panic, rsync allow us to resume a failed scp transfer :

 

rsync --partial --progress --rsh=ssh user@server:path/my_fileĀ /home/my_file

 

A quick and dirty method to launch one or more scripts as daemon with nohup

A quick and dirty method to launch one or more scripts as daemons with nohup :
nohup python3 myscript.py

You can safely close the terminal and your script will continue to operate in background.

© 2019 Tips Linux

Theme by Anders NorenUp ↑