Skip to content

Tag: bash

core dumped message is not captured in STDERR

I used to call my program with this line in bash shell to capture all stdout and stderr messages in the log file The log file shows no error but by examining the log, it’s obvious that there’s a problem and program terminates abruptly in the middle of execution. I have also tried these but the res…

Get Subnet mask in Linux using bash

I am using bash to get the IP address of my machine with that script: And now I am trying to get the Subnet Mask in this type: But I have no idea how can I do that. Answer there are couple of ways to achieve this: first: to print the mask in format 255.255.255.0, you can use this: second:

Circular SSH Tunnel

Is is possible to create a circular SSH Tunnel? local1 >SSH_TUNNEL> remote1 >SSH_TUNNEL> local1 On “Remote1” I create a TAR that I want to pipe to STDOUT ( – ) … can I then TAR – . | >SSH_TUNNEL> local1 ssh user@remote1 “tar -cvf – . | ssh user@local…

Combining two bash commands

If found this code which gives pi Ip address and this which sends 1.2.3.4 off to dweet.io stream How can I get the output from 1st to replace the 1.2.3.4 in second please? Answer Save the output of the first command in a variable: Btw, if your raspberrypi is running raspbian, then a much cleaner way to get th…

Script to generate MD5 hash with openssl

I’m trying to generate some MD5 hashes with openssl for use with chpasswd Ex. CSV file: Script I created: However, if I take any MD5 generated from this script and try to use it with chpasswd it does not work. This password will fail If I try to do this without the script by hand it works: Answer Your C…

Using a shell commands in c++

Here’s a terminal command: Here’s my code: The above code, when run, returns this message: How can I place the ‘/’ symbol, for this command to work correctly? Answer Your problem is not in C++. You are invoking your command with popen, and popen runs your command in sh shell, that does…