Use the ATOM editor behind a proxy on Windows 10

I came across this public domain editor and decided to install it to use it for uploading firmware to my SONOFF devices (TUTORIAL: Install Sonoff-Tasmota Firmware on your Sonoff Device). Unfortunately I wasn’t able to download packages for it because of our proxy server. Whatever I tried I wasn’t able to find a way to configure the proxy. I finally found a solution that worked for me.
Just execute the following commands in a console window:

  1. Run CMD as administrator
  2. cd into the directory ‘C:\Users\<your user name>\AppData\Local\atom\bin’
  3. execute ./apm config set http-proxy http://<your proxy>:<proxy port>
  4. execute ./apm config set https-proxy http://<your proxy>:<proxy port>
  5. execute ./apm config set proxy http://<your proxy>:<proxy port>

I don’t know if number 5 is really necessary but I added it just in case.
You can check the current settings by executing:
./apm config get

I hope that this will help.

Posted in Applications, Windows | Leave a comment

How to strip a certain number of Bytes from the end of a file in bash

To crop the last n Bytes from a file you can use the truncate command.
[u_r_the_man@TESTBOX ~]$ truncate --size=-n <filename>
Where n represents the number of Bytes to cut from the end of <filename>. The advantage is that the command will cut the bytes straight from the file so you don’t have to redirect the output of a command (e.g. cut) to another file.

Posted in Bash, Beginner, Linux | Leave a comment

Execute multible commands on a remote machine using SSH

To execute a number of commands on a remote machine you can create a file that contains the commands that you want to execute. This file can then be ‘cat’ed to your ssh command. I wrote one command file to test the functionality and called it ‘remoteCommands’. As you can see it is even possible to use constructs like if clauses.

if [ -e /sbin/vxdisk ]
        vxdisk list | grep -v disk_0 | awk '{ print $1"    "$4"    "$3 }'

The script is getting a list of known LUNs from servers on the network. The output will look like the one below:

[root@testclient ~]# cat bin/remoteCommands | ssh testdb1
Pseudo-terminal will not be allocated because stdin is not a terminal.
emc_clariion0_101    ztkuatjrn_dg    ztkuatjrn_dsk
emc_clariion0_102    ensuatjrn_dg    ensuatjrn_dsk
emc_clariion0_201    ztkuatdb_dg    ztkuatdb_dsk
emc_clariion0_202    ensuated_dg    ensuated_dsk
emc_clariion0_403    ztkuatewd_dg    ztkuatewd_dsk
emc_clariion0_501    ztkbase_dg    ztkbase_dsk-a
emc_clariion0_541    ensbaseed_dg    ensbaseed_dsk

The warning about the ‘Pseudo-terminal’ can be suppressed by using the ssh option -T.

Posted in Bash, Beginner | Leave a comment

Send output of a bash script to the console and to a file

Sometimes it is necessary to send the output of a script to different targets. If you want to send the output to a text but want to be able to see it on the console as well you can use the tee command.
Here is an example on how to use it in a bash script:

exec > >(tee $OUTPUTFILE)
 exec 2>&1

The first line uses process substitution to create a pipe which will then be connected to a tee process. The first > is the redirection of the file descriptor(1 stands for stdout) and the second > in combination with the () does the process substitution.
The second line redirects the stderr(2) file descriptor to whatever number 1 is already redirected to.

Posted in Bash, Beginner | Leave a comment