Sunday, September 19, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


As hardware developer (like arduino board etc.), Does one have to license PCB's files under GPLv2/3 if it's software use (go with) GPL licensed parts?

Posted: 19 Sep 2021 09:45 AM PDT

I'm just trying to understand opensource licenses as a hardware dev.

Also I'm not fully understanding GPLv3 about Tivoization part.
So If I use GPLv3 software parts, Do I obligated to design PCB that allows future re-flashing for end users?
(I sometimes like to design PCB with breakable parts that'll used only once to flash code like these https://i.stack.imgur.com/nFg2Z.jpg -> it's for saving precious space in application, also not my photo)

How to read multiple variables from a file

Posted: 19 Sep 2021 09:39 AM PDT

Example File

oj Orange Juice

10 100

A half gallon of orange juice.

This is what I did and it worked

while read -r simpleName itemName; do          read currentQuantity maximumQuantity          read description            echo "Item Name: $itemName"          echo "Simple Name: $simpleName"          echo "Item Number: $itemNumber"          echo "Qty: $currentQuantity/$maximumQuantity"          echo "Description: $description"      done < $FILE  

Note: Item number is prompted from the user prior to this and it determines which file to open.

This while loop correctly reads the file, stores the variables, and gives the desired output. The issue is, I used this same exact while loop two more times and it's not working. For some reason in the other two scenarios, simpleName and itemName are coming up blank, but the rest are working correctly.

Here's an example of where it is NOT working

#!/bin/bash    echo ""  read -p "Enter an item number: " itemNumber  echo ""    FILE="./data/${itemNumber}.item"  date=`date "+%Y-%m-%d %H:%M:%S"`    if test -f $FILE; then        if test -f ./data/queries.log; then          echo "DELETED: $date - $simpleName" >> ./data/queries.log      else          > ./data/queries.log          echo "DELETED: $date - $simpleName" >> ./data/queries.log      fi        while read -r simpleName itemName; do          read currentQuantity maximumQuantity          read description      done < $FILE        rm $FILE        echo "$simpleName was successfully deleted."  else      echo "ERROR: item not found."  fi  

Here, the output comes out incorrectly as

was successfully deleted

So $simpleName is blank for some reason. I can't figure out why it works in the first instance but not this instance.

Note: Both instances are within separate script files.

I'm aware that there are simpler ways to do things, however, I'm restricted to very very basic commands, I am not allowed to use sed, awk, grep, find, pretty much just what you see below.

Chicken-egg problem with the shebang line [duplicate]

Posted: 19 Sep 2021 08:33 AM PDT

The first line of any shell script must be the shebang line. The shebang line tells which interpreter should be used to execute the shell script.

But it seems there's some logic issue here:

  • If the shell script is not executed, it cannot be known which interpreter to use.
  • If it is unknown which interpreter to use, who should read the shebang line?

This looks like a chicken-egg problem.

Or is there some meta-interpreter?

Could anyone shed some light? Thanks.

VirtualBox Whonix VM: WiFi doesn't work :(

Posted: 19 Sep 2021 08:18 AM PDT

I am having a problem that I just can't fix, no matter what I try. :(

I am using Fedora 34 and installed VirtualBox. I am launching a Whonix VM on it. Sadly, the WiFi doesn't work on it. I am having the default settings (NAT). Whonix Gateway as well as Whonix Workstation are both running. Whonix Workstation's Device settings says NAT, "Enable Network Adapter" is enabled, and "Cable connected" as well. On Whonix Gateway too. If you need more logs, please tell me which command I have to use for the output I can give you then.

I have recently used the following command to update my Whonix Workstation (the Gateway update worked well).

sudo apt-get-update-plus dist-upgrade

Unfortunately, this didn't work. This is the output I got:

$ sudo apt-get-update-plus dist-upgrade  Ign:1 tor+https://deb.debian.org/debian bullseye InRelease                       Ign:2 tor+https://fasttrack.debian.net/debian bullseye-fasttrack InRelease       Ign:3 tor+https://deb.whonix.org bullseye InRelease                              Ign:4 tor+https://deb.debian.org/debian bullseye-updates InRelease               Ign:2 tor+https://fasttrack.debian.net/debian bullseye-fasttrack InRelease       Ign:3 tor+https://deb.whonix.org bullseye InRelease                              Ign:5 tor+https://deb.debian.org/debian-security bullseye-security InRelease     Ign:3 tor+https://deb.whonix.org bullseye InRelease                              Ign:2 tor+https://fasttrack.debian.net/debian bullseye-fasttrack InRelease       Ign:6 tor+https://deb.debian.org/debian bullseye-backports InRelease             Err:3 tor+https://deb.whonix.org bullseye InRelease                                Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Err:2 tor+https://fasttrack.debian.net/debian bullseye-fasttrack InRelease         Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Ign:1 tor+https://deb.debian.org/debian bullseye InRelease                       Ign:4 tor+https://deb.debian.org/debian bullseye-updates InRelease  Ign:5 tor+https://deb.debian.org/debian-security bullseye-security InRelease  Ign:6 tor+https://deb.debian.org/debian bullseye-backports InRelease  Ign:1 tor+https://deb.debian.org/debian bullseye InRelease   Ign:4 tor+https://deb.debian.org/debian bullseye-updates InRelease  Ign:5 tor+https://deb.debian.org/debian-security bullseye-security InRelease  Ign:6 tor+https://deb.debian.org/debian bullseye-backports InRelease  Err:1 tor+https://deb.debian.org/debian bullseye InRelease     Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Err:4 tor+https://deb.debian.org/debian bullseye-updates InRelease    Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Err:5 tor+https://deb.debian.org/debian-security bullseye-security InRelease    Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Err:6 tor+https://deb.debian.org/debian bullseye-backports InRelease    Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Reading package lists... Done                                E: Failed to fetch tor+https://deb.debian.org/debian/dists/bullseye/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Failed to fetch tor+https://deb.debian.org/debian/dists/bullseye-updates/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Failed to fetch tor+https://deb.debian.org/debian-security/dists/bullseye-security/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Failed to fetch tor+https://deb.debian.org/debian/dists/bullseye-backports/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Failed to fetch tor+https://fasttrack.debian.net/debian/dists/bullseye-fasttrack/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Failed to fetch tor+https://deb.whonix.org/dists/bullseye/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Some index files failed to download. They have been ignored, or old ones used instead.  user@host:~$ sudo apt-get-update-plus dist-upgrade  Ign:1 tor+https://fasttrack.debian.net/debian bullseye-fasttrack InRelease       Ign:2 tor+https://deb.whonix.org bullseye InRelease                              Ign:3 tor+https://deb.debian.org/debian bullseye InRelease                       Ign:4 tor+https://deb.debian.org/debian bullseye-updates InRelease               Ign:1 tor+https://fasttrack.debian.net/debian bullseye-fasttrack InRelease       Ign:2 tor+https://deb.whonix.org bullseye InRelease                              Ign:1 tor+https://fasttrack.debian.net/debian bullseye-fasttrack InRelease       Ign:2 tor+https://deb.whonix.org bullseye InRelease                              Ign:5 tor+https://deb.debian.org/debian-security bullseye-security InRelease     Ign:6 tor+https://deb.debian.org/debian bullseye-backports InRelease             Err:1 tor+https://fasttrack.debian.net/debian bullseye-fasttrack InRelease         Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Err:2 tor+https://deb.whonix.org bullseye InRelease                                Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Ign:3 tor+https://deb.debian.org/debian bullseye InRelease   Ign:4 tor+https://deb.debian.org/debian bullseye-updates InRelease  Ign:5 tor+https://deb.debian.org/debian-security bullseye-security InRelease  Ign:6 tor+https://deb.debian.org/debian bullseye-backports InRelease  Ign:3 tor+https://deb.debian.org/debian bullseye InRelease   Ign:4 tor+https://deb.debian.org/debian bullseye-updates InRelease  Ign:5 tor+https://deb.debian.org/debian-security bullseye-security InRelease  Ign:6 tor+https://deb.debian.org/debian bullseye-backports InRelease  Err:3 tor+https://deb.debian.org/debian bullseye InRelease     Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Err:4 tor+https://deb.debian.org/debian bullseye-updates InRelease    Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Err:5 tor+https://deb.debian.org/debian-security bullseye-security InRelease    Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Err:6 tor+https://deb.debian.org/debian bullseye-backports InRelease    Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  Reading package lists... Done                                E: Failed to fetch tor+https://deb.debian.org/debian/dists/bullseye/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Failed to fetch tor+https://deb.debian.org/debian/dists/bullseye-updates/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Failed to fetch tor+https://deb.debian.org/debian-security/dists/bullseye-security/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Failed to fetch tor+https://deb.debian.org/debian/dists/bullseye-backports/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Failed to fetch tor+https://fasttrack.debian.net/debian/dists/bullseye-fasttrack/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Failed to fetch tor+https://deb.whonix.org/dists/bullseye/InRelease  Read error - read (104: Connection reset by peer) Reading the greet back from SOCKS proxy socks5h://127.0.0.1:9050 failed [IP: 127.0.0.1 9050]  E: Some index files failed to download. They have been ignored, or old ones used instead.  

Thank you very much!

Router blocking one specific device

Posted: 19 Sep 2021 09:14 AM PDT

I'm trying to connect my computer to the internet via a new router, and it is refusing to work in the most baffling way I've ever encountered.

  1. If I just connect to the wifi network in the normal way,

    Computer --(Wifi)--> Router  

    then I can ping the router without problems. But I cannot ping 8.8.8.8:

    PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.  

    Needless to say, I also can't access any other websites.

  2. If I instead use ethernet,

    Computer --(Ethernet)--> Router  

    then things are exactly the same as (1), showing it's not a wifi issue.

  3. I then connected two additional phones to the router, like this

    Computer --(Wifi)--> Router  Phone 1  --(Wifi)--> Router  Phone 2  --(Wifi)--> Router  

    Both phones could access the internet fine, and all three devices could ping each other and the router, but the computer still couldn't access the internet.

  4. I tried connecting the computer via USB tethering, using a phone as an intermediary:

    Computer --(USB tethering)--> Phone --(Wifi)--> Router  

    The computer still couldn't connect to the internet. But note that when I switched the phone to mobile data,

    Computer --(USB tethering)--> Phone --(Mobile Data)--> Mobile Network  

    things worked fine, which shows the tethering setup was not at fault.

Things I have tried

  • Using other routers (in the past). They have all worked.

  • I have ensured that the computer's wireless regulatory domain is set correctly.

  • Rebooting the router.

  • I am not allowed to reset the router.

  • Faking the computer's MAC address. This made no difference, except when using ethernet, now I couldn't even connect to the router at all.

  • Using mtr. If I run mtr 8.8.8.8, I get

     Host   1. _gateway   2. 10.12.0.1   3. (waiting for reply)  

    I recognise 10.12.0.1 as the address of the router. But it never gets any further than that, and certainly doesn't make it to dns.google.

  • Disabling TCP window scaling as suggested on the Arch Wiki. This was a complete shot in the dark. It also didn't work.

  • Running a Debian LiveUSB instead of Arch Linux.

  • Lowering the mtu from 1500 to 128. [added]

Other useful information [added]

  • The contents of /etc/resolv.conf:

     # Generated by NetworkManager   nameserver 127.0.0.1   options edns0 trust-ad  
  • The contents of NetworkManager.conf:

     [main]   plugins=keyfile   dns=dnsmasq   dhcp=internal  
  • The system log upon connecting via ethernet:

    https://pastebin.com/rAQqjvmk

Summary

It seems this router has it in for my computer no matter what I do. Somehow it even recognises my computer when it's hiding behind my phone, with a fake MAC address, and with a fresh operating system. At this point, my best guess is that some hardware identifying information is somehow getting into the ping packets, and that something after the router is blacklisting it. So, the questions are the obvious ones:

  • What could be causing it not to work?
  • How do I make it work?

How to gain shell access to IoT device which lets me execute ANY shell script via its update functionality?

Posted: 19 Sep 2021 07:35 AM PDT

I have this IoT device that I want to analyse and try to gain root access to. I can connect to it via ssh/PuTTY but obviously don't have any login information.

In one of the firmware updates for this device, I discovered that I can upload any .tar.bz2 archive to its webserver which then gets extracted and a update.sh script from the archive will be executed with /bin/sh. The "firmware" update actually just replaces some binaries and then restarts the device. No ROM flashing or something like that.

My question is: How can I gain access to a shell on this system? I mean, it seems like I can upload ANY archive containing a custom script to it which will then get executed. This must be jackpot right?

Unfortunately, I am too much of a noob to come up with a solution for this. As a first step, I tried to execute some commands like whoami or users via the script, write the output to a file and then transfer the log via scp to my other machine but unfortunately, this doesn't seem to be possibile in a non-interactive way.

how to join inventory items in a comma delimited list?

Posted: 19 Sep 2021 07:43 AM PDT

I have ansbile inv

# cat inv  [all]  vm1  vm2  

I want to extract them in a comma delimited list using Jinja template

so I add jinja template

# cat comb_list.j2    {{ groups['all'] | map('extract', hostvars, ['item']) | join(',') }}"  

but I guess item is not a hostvars, so throws error

I want end file to look like this

# cat comb_list  vm1,vm2  

Can't rm directory in /mnt

Posted: 19 Sep 2021 09:28 AM PDT

read a bunch of posts about similar issues but can't get it working.

I mount a folder on my RPi that sits on my Hackintosh. I use it for backup. Lately I keep getting this error: enter image description here

I have set the permissions to 777 but still no go: enter image description here

Any suggestions on where to begin? Thanks for your help!

Edit: I'm sorry, I didnt realize I shouldnt insert images. Took me a few min to edit it. Here is the code in the script I run via cron:

#!/bin/sh  sudo mount.cifs //10.0.2.20/"RPi Backup" /mnt/netbackup -o   user=xxxxxxxx,password=xxxxxxx umask=000sudo               /usr/local/bin/raspiBackup.sh  

Custom URI handling: xdg-open and Firefox work, but Chrome doesn't

Posted: 19 Sep 2021 08:33 AM PDT

I'm trying to configure my Linux environment to open obsidian:// URIs using the Obsidian app (see Using Obsidian URI).

This is the flow I'm using. I'm doing this on a clean Ubuntu machine to make sure it reproduces:

  1. The Obsidian.AppImage file is stored in ~/obsidian alongside an icon.jpg file. The AppImage file has execute permissions.

  2. This is my ~/.local/share/applications/obsidian.desktop file's content:

    [Desktop Entry]  Name=Obsidian  Exec=/home/rachum/obsidian/Obsidian.AppImage %u  Terminal=false  Type=Application  Icon=/home/rachum/obsidian/icon.png    StartupWMClass=obsidian  X-AppImage-Version=0.8.15  Comment=Obsidian  Categories=Office;  MimeType=text/html;x-scheme-handler/obsidian;  
  3. I've run update-desktop-database ~/.local/share/applications/

  4. Using xdg-open works as intended:

    xdg-open "obsidian://new?vault=notes&name=note&content=content"  

    This command line opens the Obsidian app with the new note and content.

  5. In Firefox (preinstalled), typing the above URI into the URL bar also opens the Obsidian app with the new note and content.

  6. I installed Google Chrome by downloading the .deb file from the official Chrome site and running dpkg -i <.deb file>

  7. Typing the above URI in Chrome just redirects me to a Google search for "obsidian://new?vault=notes&name=note&content=content".

Why is Chrome not respecting the XDG configuration?


Update #1: adding more details to answer comment.

My ~/.local/share/applications/mimeapps.list file looks like this:

[Default Applications]  x-scheme-handler/obsidian=obsidian.desktop  

My ~/.local/share/applications/mimeinfo.cache file looks like this:

[MIME Cache]  text/html=obsidian.desktop;  x-scheme-handler/obsidian=obsidian.desktop;  

Awk, bash : Combining multiple files with data calculations spanning several lines

Posted: 19 Sep 2021 07:07 AM PDT

I have input data files from 10 devices (numbered 0 to 9) reporting sensor data for each month. Here are some sample data and expected output.

Example data file for device0_202105.csv:

Date;Time;Timestamp;PM2_5;AQI;PM10;CO2  2021/05/01;00:00:49;1619827249;21.0;70;29.0;413  2021/05/01;00:10:49;1619827849;20.0;68;37.0;409  2021/05/01;00:20:49;1619828449;21.0;70;39.0;412  2021/05/03;08:10:39;1620029439;33.0;95;43.0;430  2021/05/03;08:20:39;1620030039;33.0;95;50.0;427  2021/05/03;08:30:39;1620030639;35.0;99;38.0;429  2021/05/03;08:40:39;1620031239;33.0;95;46.0;431  2021/05/03;18:10:39;1620065439;12.0;50;18.0;425  2021/05/03;18:20:39;1620066039;12.0;50;18.0;426  

Example data file for device0_202106.csv:

Date;Time;Timestamp;PM2_5;AQI;PM10;CO2  2021/06/01;08:19:16;1622535556;19.0;66;30.0;426  2021/06/01;08:29:16;1622536156;20.0;68;33.0;454  2021/06/01;08:39:16;1622536756;24.0;76;31.0;456  2021/06/01;20:49:16;1622580556;36.0;102;32.0;447  

Example data file for device1_202105.csv:

Date;Time;Timestamp;PM2_5;AQI;PM10;CO2  2021/05/03;11:14:59;1620040499;19.0;66;20.0;438  2021/05/03;11:15:09;1620040509;19.0;66;20.0;486  2021/05/03;11:15:19;1620040519;18.0;63;18.0;485  

I would like to create one file per type of sensor (e.g. CO2) for the whole available data period (here 202105 and 202106) that would look like this data-co2.csv using the above data:

Date;Time;Device 0;Device 1  2021/05/03;10:30;429.25;469.667  2021/06/01;10:30;475.333  

The data for each device is reported in columns and each data point is an average over a certain time interval. So one line reports the average value for a time interval of the original data.

I'm considering initially only 2 time intervals for each weekday only: a morning time interval from 8:00 to 13:00 (labeled 10:30) and an afternoon time interval from 13:00 to 18:00 (labeled 15:30).

I planned to run an awk script launched by a bash script that would loop over device and period files. Here is the beginning of my scripts. However, I'm having trouble writing to the output file (should I use the -inplace option ?). I'm thinking about an easier route : write to a temp file and concatenate to the output file later.

#!/bin/bash  touch data-co2.csv  gawk -v device=0 -v sensor=18 -f read-data.awk device0_202105.csv data-co2.csv  
#!/bin/gawk -f  BEGIN {      FS  = "[;/:]";      OFS = ";";      day  = 1 ;      sam = 0 ; nam = 0 ; spm = 0 ; npm = 0 ;  }  FNR==NR {      if ( $1 ~ /20[0-9]{2}/ ) {          if ( $3 != day ) {              if ( nam != 0 ) a[$1"/"$2"/"$3";10:30"] = sam / nam ;              if ( npm != 0 ) a[$1"/"$2"/"$3";15:30"] = spm / npm ;              day = $3 ;              sam = 0 ; nam = 0 ; spm = 0 ; npm = 0 ;          }          if ( strftime("%u", $7, 1) < 6) {              if ( $4 >= 8 && $4 <= 12 ) {                  sam += $sensor ;                  ++nam ;              }              else if ( $4 >= 13 && $4 < 18 )  {                  spm += $sensor ;                  ++npm ;              }          }      next ;      }  }  {      if ( device == 0 ) {         for ( i in a ) {             print i, a[i] ;         }      }      else {         i = $1"/"$2"/"$3";10:30" ;         j = $1"/"$2"/"$3";15:30" ;         print $0, a[i] ;         print $0, a[j] ;      }  }  

Please note that each device reports data at different times and that data may be missing due to device malfunction, network issue, etc.

Edited following the comments.

cdo command to rename the file on specific after some operation using bash script

Posted: 19 Sep 2021 07:50 AM PDT

I have a lot of nc file and i want to some operation to all of the and to change the name in specific way for example :

form this name prAdjust_EUR-11_CNRM-CERFACS-CNRM-CM5_rcp45_r1i1p1_CLMcom-CCLM4-8-17_v1-SMHI-DBS45-MESAN-1989-2010_day_19860101-19901231.nc

to

prAdjust_EUR-11_CNRM-CERFACS-CNRM-CM5_rcp45_CLMcom_day_mm_jordan_1986-1990.nc

but i did not know how to start using Shell script

**the command i use is **

cdo mulc,86400  old name  prAdjust_EUR-11_CNRM-CERFACS-CNRM-CM5_rcp45_CLMcom_day_mm_1986-1990.nc  

then

cdo -L -P 8 -sellonlatbox,33.5,41.0,27.0,35.5 -remapbil,global_0.1  prAdjust_EUR-11_CNRM-CERFACS-CNRM-CM5_rcp45_CLMcom_day_mm_1986-1990.nc  prAdjust_EUR-11_CNRM-CERFACS-CNRM-CM5_rcp45_CLMcom_day_mm_jordan_1986-1990.nc  

like this  for all nc file

Are there attempts to develop a more accessible sed?

Posted: 19 Sep 2021 10:05 AM PDT

sed pseudocode:

sed      "FROM"          $to = ".*";$      "TO"          $to = "'"$new_email_address"'";      "GLOBAL"  FILE_PATH  
  • Mere line breaks are allowed
  • Tab indentation is allowed
  • There is no necessity to use single line segmentation
  • There is no necessity to wrap commands in quote marks as with sed "/s/X/Y/g" FILE
  • Using a data structure such as "'"$new_email_address"'" in the above example would be easier because it won't be situated inside a dense long line which is already quote marked; if the shell must have a wrap to process the code, the wrapping could be done with some new character just for strings (STRING_WITH_VARIABLEEXPANSION data STRING_WITH_VARIABLEEXPANSION) instead mixing quote marks

I would be happy to work with such a sed, because I find it more accessible and ordinal than the regular syntax, hence the question in title.

How to wrap this command in a bash script?

Posted: 19 Sep 2021 06:10 AM PDT

I have an existing bash script that I call like this:

find /path/to/my/stuff -type d -exec sh -c 'cd "$0"; /path/to/my/script.sh function_name fn_parameter' {} \;  

I frequently change the /path/to/my/stuff and fn_parameter. I also need to sometimes change the function_name.

It's getting tedious to keep retyping this command, so I would like to wrap it in another script and pass just those three parameters like this:

wrapper.sh function_name "/path/to/my/stuff" fn_parameter  

Side note: I changed the order of the arguments because "function_name" is the one that changes least frequently.

I am getting overwhelmed by quoting and escaping when I try to make this wrapper script. I looked at the script in shellcheck.net and I also tried using an array for cmd (refer to one of my failed attempts below) without success. I do understand that the problem is most likely that quotes and backslashes are not being respected, but I cannot understand how to solve that.

This is one of my many failed attempts:

wrapper.sh

#!/bin/bash  function_name=$1  mpath="$2"  arg=$3    find "$mpath" -type d -exec sh -c "cd \"$0\"; /path/to/my/script.sh $function_name $arg" {} \;  

Here's another example of a failed attempt:

#!/bin/bash  function_name=$1  mpath="$2"  arg=$3  cmd="'cd \$0; /path/to/my/script.sh $function_name $arg'"  echo "find \"$mpath\" -type d -exec sh -c $cmd {} \;"  find "$mpath" -type d -exec sh -c $cmd {} \;  

In the above example, if I enter the output of the echo statement on the command line, it works correctly. But the wrapper fails with:

$0;: -c: line 1: unexpected EOF while looking for matching `''  $0;: -c: line 2: syntax error: unexpected end of file  

For completeness, myscript.sh is similar to this:

#!/bin/bash    fn1() {    ...  }    fn2() {    ...  }      fn3() {    ...  }    "$@"  

CentOS 7 - Where to add FTP port?

Posted: 19 Sep 2021 09:45 AM PDT

I have a VM with no firewalld or iptables services running. I need to set up an ftp server. I am unable to connect and ends up with 421 service not available error. However I could find the vfstpd service running and have disabled selinux.

Trying to debug/understand.. How/where can I add the ftp port in the server? Should I explicitly add or the default (21) would be picked automatically?

Have not used linux much. Your thoughts would be helpful. Thank you

UPDATE

[root@L00096a log]# ss -lt  State       Recv-Q Send-Q                               Local Address:Port                                                Peer Address:Port  LISTEN      0      50                                               *:microsoft-ds                                                   *:*  LISTEN      0      50                                               *:netbios-ssn                                                    *:*  LISTEN      0      128                                              *:ssh                                                            *:*  LISTEN      0      50                                            [::]:microsoft-ds                                                [::]:*  LISTEN      0      50                                            [::]:netbios-ssn                                                 [::]:*  LISTEN      0      32                                            [::]:ftp                                                         [::]:*    

Inability to change monitor's display

Posted: 19 Sep 2021 06:15 AM PDT

It seems that my monitor's display can't be changed from 1024 x 728. I read that this may be due to a new update. I use Linux Mint 20.2 Uma. Should I try updating my GPU drivers? Should I move to an older version? Is there anything else that may be the problem? I have an Intel Corporation Haswell-ULT Integrated Graphics Controller.

Extract files name from .7z format file one by one and send the name as parameter to a java program from terminal

Posted: 19 Sep 2021 10:02 AM PDT

I am trying to write a bash script that will first extract files one by one and call a java program with the file name as parameter to do some stuff. I have tried with the following stuff but it does not work. I am facing the following problem.

The zip file name is compressed.7z. There are 2 files inside the compressed.7z file. sample_1.json and sample_2.json (can be anything). The 7z command always give the compressed.7z as file name which I don't want. I just want to get extract sample_1.json in the output folder and give the name to the java command then sample_2.json in the next iteration. Could anybody can help in this issues?

Thanks in advance.

  for file in *.7z   do     7za x -ooutput  "${file}" | java -jar Remove_BoilerPlate_JSON_Updated.jar "${file}";  done    

"Permission denied" with ffmpeg (via snap) on external drive

Posted: 19 Sep 2021 08:35 AM PDT

I got a new drive and I can copy files fine with simple cp on the drive. However for some weird reason I get Permission denied with ffmpeg.

Permissions seem fine unless I'm missing something

> ll /media/manos/6TB/  drwxrwxrwx  13 manos      4096 Apr 16 00:56  ./  drwxr-x---+  6 manos      4096 Apr 16 00:49  ..  -rwxrwxrwx   1 manos 250900209 Apr 15 17:28  test.mp4*  ..  

But ffmpeg keeps complaing

> ffmpeg -i test.mp4 test.mov  ffmpeg version n4.1.4 Copyright (c) 2000-2019 the FFmpeg developers    built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)    configuration: --prefix= --prefix=/usr --disable-debug --disable-doc --disable-static --enable-avisynth --enable-cuda --enable-cuvid --enable-libdrm --enable-ffplay --enable-gnutls --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopus --enable-libpulse --enable-sdl2 --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-nonfree --enable-nvenc --enable-omx --enable-openal --enable-opencl --enable-runtime-cpudetect --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-xlib    libavutil      56. 22.100 / 56. 22.100    libavcodec     58. 35.100 / 58. 35.100    libavformat    58. 20.100 / 58. 20.100    libavdevice    58.  5.100 / 58.  5.100    libavfilter     7. 40.101 /  7. 40.101    libswscale      5.  3.100 /  5.  3.100    libswresample   3.  3.100 /  3.  3.100    libpostproc    55.  3.100 / 55.  3.100  test.mp4: Permission denied  

Simply copying like below works fine..

> cp test.mp4 test.mp4.bak  'test.mp4' -> 'test.mp4.bak'  

Any ideas on what is going on? This is pretty annoying. Note ffmpeg is installed at /snap/bin/ffmpeg

How to clear history in zsh

Posted: 19 Sep 2021 09:29 AM PDT

I'm looking for the zsh equivalent of the bash command history -c, in other words, clear the history for the current session. In zsh history -c returns 1 with an error message history: bad option: -c.

Just to clarify, I'm not looking for a way to delete the contents of $HISTFILE, I just want a command to reset the history to the same state it was in when I opened the terminal. Deleting the contents of $HISTFILE does the opposite of what I want: it deletes the history I want to preserve and preserves the history I want to delete (since current session's history would get appended to it, regardless if its contents was previously erased).

There is a workaround I use for now, but it's obviously less than ideal: in the current session I set HISTFILE=/dev/null and just close and reopen the terminal. This causes the history of the closed session not be appended to $HISTFILE. However, I'd really like something like history -c from bash, which is much more elegant than having to close and restart the terminal.

What are file-level snapshots , is there any file system that supports this feature?

Posted: 19 Sep 2021 06:49 AM PDT

I am trying to understand what are file level snapshosts. Anyone has idea as to which filesystems supports this so that I can try it out.

Ref. http://tracker.ceph.com/issues/24464

Enabling networking in a systemd-nspawn container

Posted: 19 Sep 2021 08:05 AM PDT

I'm trying to setup container that has access to the internet but have been unsuccessful so far.

# sudo systemd-nspawn -nb -M debian-tree  # systemctl enable --now systemd-networkd systemd-resolved  # ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf  # ip link  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  2: host0@if8: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN mode DEFAULT group default qlen 1000      link/ether 42:ca:d5:8c:af:60 brd ff:ff:ff:ff:ff:ff link-netnsid 0  # ping google.com  ping: google.com: Temporary failure in name resolution  

On the host

# ip link  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  2: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000      link/ether 7c:7a:91:ae:7d:47 brd ff:ff:ff:ff:ff:ff  8: ve-debian-tree@if2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000      link/ether 92:f7:e1:4b:c6:6f brd ff:ff:ff:ff:ff:ff link-netnsid 0  

Any ideas why it's not working?

How to see what port was blocked in iptables log file?

Posted: 19 Sep 2021 10:06 AM PDT

I have created few iptables rules and I have tested them. I created INPUT, OUTPUT chains using following code:

  #!/bin/bash        iptables -F    iptables -P INPUT DROP  iptables -P OUTPUT DROP  iptables -P FORWARD DROP    iptables -N accept-input    iptables -A accept-input -j LOG --log-prefix "INPUT-ACCEPTED "  iptables -A accept-input -j ACCEPT      iptables -N drop-input    iptables -A drop-input -j LOG --log-prefix "INPUT-DROPPED "  iptables -A drop-input -j DROP    iptables -N accept-output    iptables -A accept-output -j LOG --log-prefix "OUTPUT-ACCEPTED "  iptables -A accept-output -j ACCEPT    iptables -N drop-output    iptables -A drop-output -j LOG --log-prefix "OUTPUT-DROPPED "  iptables -A drop-output -j ACCEPT    iptables -A INPUT -j drop-input  iptables -A OUTPUT -j drop-output  

and I have added other rules to allow specific ports. I want to see the DROPPED packets. I am using port 9191 for IIS websites. I can't reach websites because it is being blocked.

Solaris 11 in Maintenence mode: nfs mount: : RPC: Rpcbind failure - RPC: Unable to receive

Posted: 19 Sep 2021 09:08 AM PDT

There is an issue with Solaris 11 machine and it boots automatically to the single user mode.We can see the error message "nfs mount: : RPC: Rpcbind failure - RPC: Unable to receive". The machine is a LDom . I booted through OS Image and found that there was an entry in vfstab corresponding to the same. It was removed and tried to start the server again but still the same.enter image description here

I cross checked and there was no entries in dfstab.As in attached image we can see that the network milestone is maintenance mode.

Kindly guide me what further investigation and action need to be taken as this is an critical server and need to solve the issue asap.

Kindly let me know if any further info required.

How can I print a variable with padded center alignment?

Posted: 19 Sep 2021 09:30 AM PDT

How can I print $myvar padded so that it is in the center of the terminal, and to either side are = to the edge of the screen?

Does the O_DIRECT flag bypass the Linux page cache when accessing block devices too?

Posted: 19 Sep 2021 07:16 AM PDT

I am running a lot of KVM virtual machines, which open the hard disk image with the O_DIRECT flag.

I understand, according to the open() man page, that using O_DIRECT will try to bypass the Linux page cache when writing to a file, but does that apply to block devices as well? (for instance when the hard disk image is a LVM volume, or a ZFS zvol)

NB: the use case of O_DIRECT here, is that the guest is already maintaining its own page cache, so it makes no sense to duplicate that on the host.

Starting Wait for Plymouth Boot Screen to Quit

Posted: 19 Sep 2021 06:05 AM PDT

I'm struggling to install Kubuntu 15.04 on my PC. I've got a GTX 970 which i think is throwing off the trial mode from starting up. nomodeset doesn't work, so I tried nouveau.noaccel=1 to beget this error screen. At this point I don't fully understand how to proceed, so any help would be great.

enter image description here

opening multiple URLs from a text file as different tabs in Firefox/Chrome?

Posted: 19 Sep 2021 09:02 AM PDT

How I would go about opening multiple URLs from a text file as different tabs in Firefox/Chrome? My text file is just a list of URLs, one per line:

http://www.url1.com  http://www.url2.com  http://www.url3.com  http://www.url4.com  

How to change user on SWAT page (or how to control Samba by nonprivileged user)

Posted: 19 Sep 2021 07:01 AM PDT

I logged into SWAT with my nonprivileged user, since the root account is usually disabled on modern Linux systems. I cannot control any Samba parameters by this user. Once I enable the root account, how should I logout from SWAT and re-login into SWAT as root?

Or how should I make my nonprivileged user to be able to control Samba parameters? Put the user into certain group? Specify the user in some SWAT config as a privileged one?

No comments:

Post a Comment