linux:nice-to-know

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:nice-to-know [2019/05/06 16:50] michaellinux:nice-to-know [2019/05/06 17:33] (current) michael
Line 117: Line 117:
 </WRAP> </WRAP>
  
 +----
 +
 +<WRAP center round box 100%>
 +''<wrap hi>**curl only write to file if successful status 200**</wrap>''
 +
 +Make curl get the contents of a URL and write to file, but only write to file if the response is successful:
 +
 +<code># curl -s -S -f -o blackgate-feed.json "$blackgate_rz"</code>
 +
 +  * -s keeps curl quiet by hiding progress meter and error messages
 +  * -S shows an error message if it fails (stderr)
 +  * -f Fail silently (no output at all) on server errors, keeping stdout clean
 +  * -o specifies an output file
 +
 +</WRAP>
 +
 +----
 +
 +<WRAP center round box 100%>
 +''<wrap hi>**Pipe video stream from raspberry pi to local computer with ffplay**</wrap>''
 +
 +I use this to get a live video stream from my Raspberry Pi with Camera attached
 +
 +Execute this on the Pi, where TARGET_IP is my local computer where I will watch the stream, and PORT is an arbitrary port number.
 +
 +<code># raspivid -t 999999 -o - | nc -u $TARGET_IP $PORT</code>
 +
 +Execute this on the local computer where you will watch the video stream
 +
 +<code># nc -ul $PORT | ffplay -</code>
 +
 +----
 +
 +  * https://www.raspberrypi.org/blog/camera-board-available-for-sale/
 +  * https://blog.philippklaus.de/2013/06/using-the-raspberry-pi-camera-board-on-arch-linux-arm/
 +
 +</WRAP>
 +
 +----
 +
 +<WRAP center round box 100%>
 +''<wrap hi>**Generating a pseudorandom password or string in Linux bash**</wrap>''
 +
 +''Define a function in e.g. **~/.bashrc**''
 +
 +<sxh plain; gutter: false;>
 +genpasswd() {
 +  tr -dc A-Za-z0-9 < /dev/urandom | head -c ${1:-36} | xargs
 +}
 +</sxh>
 +
 +Where 36 is default length if no parameter is given
 +
 +----
 +
 +**Usage**:
 +
 +<code># genpasswd
 +GVQ3ZHqrBRDzB1QwASA9uk6YsZPto2GWeRWR
 +
 +# genpasswd 7
 +qvPWx7N</code>
 +</WRAP>
  
  • linux/nice-to-know.1557154257.txt.gz
  • Last modified: 2019/05/06 16:50
  • by michael