Sunday, September 26, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


How to attach to a tmux session on a remote machine that has been started locally on that machine?

Posted: 26 Sep 2021 11:01 AM PDT

There are two physical machines in front of me: nixos and mac.

  1. Physically typing in a terminal on nixos:

    nixos$ tmux ls  0: 5 windows (created Thu Sep 16 19:21:38 2021) (attached)  1: 1 windows (created Fri Sep 17 00:50:45 2021)  2: 5 windows (created Wed Sep 22 05:37:28 2021) (attached)  4: 1 windows (created Thu Sep 23 21:51:01 2021)  
  2. Then physically typing on mac:

    mac$ ssh nixos  Last login: Sun Sep 26 13:24:58 2021 from 192.168.0.27    nixos$ tmux ls  no server running on /run/user/1000/tmux-1000/default  

Is there are a way to attach to the already existing tmux sessions when connecting from a remote machine?

nftables: how to use a unique map (or set) for both dnat & forward rule?

Posted: 26 Sep 2021 10:43 AM PDT

I am setting up a firewall + NAT using nftables (v0.9.6). The tool provides sets & maps to avoid a lot of rule duplication.

I want to use a common data structure (set or map) to configure both DNAT and filtering rules (forward).

When I try (nft --check -f example.conf), I always get an error. Do you know a way to do this without duplicating the NAT mapping into 2 data structures (one map & one set)?

Here is the example I use:

#!/usr/sbin/nft -f    table inet filter {    map portfwdv4 {      type inet_service : ipv4_addr      elements = {        12345 : 192.168.0.66,        4321  : 192.168.0.77      }    }      set mysimpleset {      type ipv4_addr . inet_service      elements = {        192.168.0.66 . 12345,        192.168.0.77 . 4321      }    }      chain natprerouting {      type nat hook prerouting priority dstnat; # =-100        # THIS YIELDS NO ERROR:      dnat ip to tcp dport map @portfwdv4        # THIS IS REFUSED AT PARSING (unexpected string: @mysimpleset):      dnat ip addr . port to @mysimpleset    }      chain forward {      type filter hook forward priority filter; # =0        # THIS IS REFUSED AT PARSING (unexpected dport)      ip daddr tcp dport map @portfwdv4 accept        # THIS YIELDS NO ERROR:      ip daddr . tcp dport @mysimpleset accept    }  }  

It would work if dnat to could accept a set. Can I convert a map into a set (or vice versa)? Is there a way?

Note: my original map is more like this (I simplified for the example, but would love to make it work as is):

  map portfwdv4 {      type inet_proto . inet_service : ipv4_addr      elements = {        tcp . 12345 : 192.168.0.66,        udp . 4321  : 192.168.0.77      }    }  

Loop a part of code for multiple variables

Posted: 26 Sep 2021 10:20 AM PDT

I am looking for an approach to build a script.

I have 3 files with the below pattern:

DailyLoad_Cust.txt  DailyLoad_Credit.txt  DailyLoad_Account.txt  

Each of these files has an associated sub_system. e.g cust has cus_edw, credit has cred_edw and account has acc_edw

There is a common load script "RunFeed.sh <<sub_system>>" which takes sub_system ( cus_edw,cred_edw,acc_edw) and runs if the file is available at NAS location and has count> 0.

What's the best approach I can use for this?

$Var1="Cust"  $Var2="Credit"  $var3="Account"    SUB_SYSTEM="";  for i in $VAR1; do    NASFileCount=`find . -maxdepth l -type f -name "${var}*.txt" | wc -l  if [[ $NASFileCount -gt 0 ]] && $Var1=cust;then   Sub_System=cust_edw      sh RunFeed.sh $Var  

In the above approach (which is raw and not run so far), how can i run the loop for all the variables above Can anyone please guide me, there is any better approach? I am relatively new to unix, still learning.

trying to ssh: Connection Refused to a server from a local ip

Posted: 26 Sep 2021 10:15 AM PDT

I tried to ssh to a remote cluster from a remote machine, and got an error "ssh: connect to host XXX port 22: Connection refused".

I tried to do the same thing, specifying port 22, and doing so from my local machine, with the same user. This works!

Since I used the same user and the same port, I can tell that my problem has to do with the IP of the remote machine or something like that, which is weird, since the cluster and machine are a part of the University's Network!

Any guidance with solving this problem would be much appreciated :)

Pattern matching in if block in Alpine's `sh`

Posted: 26 Sep 2021 10:53 AM PDT

How do i replicate the following bash expression:

if [[ "$foo" =~ (bar|spam) ]]; then    echo "True"  fi  

in Alpine's /bin/sh?

Typing it in as-is throws an error:

/bin/sh: syntax error: unexpected "(" (expecting "then")  

Ubuntu cannot boot because no valid partition table. How to fix it?

Posted: 26 Sep 2021 09:39 AM PDT

I am unable to boot. I have only Ubuntu installed on a computer, and it was working fine. But suddenly I am unable to boot. It says "no valid partition table".

I have attached the output I received when I issue the command "fdisk -l". I am not very familiar with Ubuntu. Therefore any help is appreciated.

Output of fdisk -l

Extract ssh key algorithm

Posted: 26 Sep 2021 09:58 AM PDT

Is there a command to extract information about the algorithm that is used (RSA, ECDSA, 3DES ...) for SSH keys, regardless of the format (pem, der etc)? I looked into openssl, but I could not find anything about this.

Debian : How to add graphics card's firmware to kernel?

Posted: 26 Sep 2021 11:01 AM PDT

I am using Debian 11(bullseye) Live from USB with "persistence" option. I had only problem remaining : loading my graphic card(Radeon HD 4350) correclty to kernel(5.10.0-8-amd64). I installed firmware-amd-graphics package and got the necessary firmware file under /usr/lib/firmware/radeon/ folder as RV710_uvd.bin. I used lspci | grep -i vga and get :

 01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] RV710 [Radeon HD 4350/4550]  

File is there but I could not load it since xrandr gives :

xrandr: Failed to get size of gamma for output default  Screen 0: minimum 640 x 400, current 1280 x 1024, maximum 1280 x 1024  default connected 1280x1024+0+0 0mm x 0mm     1280x1024      0.00*      1152x864       0.00       640x480        0.00       720x400        0.00   

So I could not achieve to load firmware to kernel. I also tried to update the initramfs(sudo update-initramfs -u) to load necessary firmware after installing firmware-amd-graphics package but it gives :

 I: update-initramfs is disabled (live system is running on read-only media).  

So I want to learn how to :

A) make live-system media(medium) as writable ? I had a USB with partitioning as :

  NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT    loop0    7:0    0  2,1G  1 loop     /usr/lib/live/mount/rootfs/filesystem.squashfs    sda      8:0    1  8,0G  0 disk     ├─sda1   8:1    1  100M  0 part     ├─sda2   8:2    1    3G  0 part /usr/lib/live/mount/medium    ├─sda3   8:3    1    3G  0 part                                      /usr/lib/live/mount/persistence/sda3  

sda1 - ext4 - for boot sda2 - ext2 - includes files of live system sda3 - ext4 - persistence storage partition

B) update initramfs successfully to load available graphics card firmware file(/usr/lib/firmware/radeon/RV710_uvd.bin)to kernel ? I am a beginner in Linux. Please, any command line help is appreciated.

Firewalld forwarded ports are reffusing connection

Posted: 26 Sep 2021 07:57 AM PDT


I have a problem with Firewalld port forwarding. The issue is that forwarded ports are refusing connections or are not responding (TCP flag RSET? on hypervisor where port forwarding is set up)

OS: Oracle Linux 8.4, kernel 4.18

The firewalld configuration:

public (active)    target: default    icmp-block-inversion: no    interfaces: enp9s0    sources:    services: cockpit dhcpv6-client http https ssh    ports: 81/tcp 55565/udp    protocols:    forward: no    masquerade: yes    forward-ports:          port=25:proto=tcp:toport=25:toaddr=192.168.1.3          port=143:proto=tcp:toport=143:toaddr=192.168.1.3          port=465:proto=tcp:toport=465:toaddr=192.168.1.3          port=587:proto=tcp:toport=587:toaddr=192.168.1.3          port=993:proto=tcp:toport=993:toaddr=192.168.1.3          port=3389:proto=tcp:toport=3389:toaddr=192.168.1.4          port=3389:proto=udp:toport=3389:toaddr=192.168.1.4    source-ports:    icmp-blocks:    rich rules:          rule family="ipv6" source address="fd00::0/121" masquerade  

Forwarded ports are open on target VM and its IPv4 address is correct (192.168.1.3):

PORT    STATE SERVICE  22/tcp  open  ssh  25/tcp  open  smtp  80/tcp  open  http  110/tcp open  pop3  143/tcp open  imap  443/tcp open  https  465/tcp open  smtps  587/tcp open  submission  993/tcp open  imaps  995/tcp open  pop3s  

Port 80 and 443 are load balanced using Nginx (as HTTP Load Balancer) and forwarding works fine.

IPv4 and IPv6 port forwarding are enabled:

# sysctl net.ipv4.ip_forward  net.ipv4.ip_forward = 1  # sysctl net.ipv6.conf.all.forwarding  net.ipv6.conf.all.forwarding = 1  

What can be the issue here?

How to show the filesystem of a logical volume (LVM)? (tldr:I/O error)

Posted: 26 Sep 2021 09:37 AM PDT

  • How to show the filesystem of a logical volume (LVM)?

lvdisplay doesn't show them and fdisk isn't suitable to work with LVM.

  • ssm tool shows some but not all: enter image description here

  • lsblk -f

enter image description here

I'd like to know the /dev/cl/root's filesystem (under /dev/sdc3 that is a physical volume).

Trying to mount one:

# mount /dev/mapper/cl-root /mnt/optiplex  mount: /mnt/optiplex: can't read superblock on /dev/mapper/cl-root.  
  • lvs: enter image description here

I can't mount the root logical volume in this group volume: enter image description here

Why don't browsers respect LC_TIME?

Posted: 26 Sep 2021 09:22 AM PDT

I'm using en_US for system language, but pl_PL for date format. It works OK in the entire system, and running date gives me a correctly formatted date. It also shows Polish as Time format in the GUI Language Settings.

But in any browser (Chrome, Chromium, Firefox) I have US format! For example in Date input, Date in JS etc...

console.log(new Date().toLocaleString())  // shows      9/26/2021, 3:29:46 PM  // should be  26.09.2021, 15:29:46   

locale:

LANG=en_US.UTF-8  LANGUAGE=en_US  LC_CTYPE="en_US.UTF-8"  LC_NUMERIC=pl_PL.UTF-8  LC_TIME=pl_PL.UTF-8  LC_COLLATE="en_US.UTF-8"  LC_MONETARY=pl_PL.UTF-8  LC_MESSAGES="en_US.UTF-8"  LC_PAPER=pl_PL.UTF-8  LC_NAME=pl_PL.UTF-8  LC_ADDRESS=pl_PL.UTF-8  LC_TELEPHONE=pl_PL.UTF-8  LC_MEASUREMENT=pl_PL.UTF-8  LC_IDENTIFICATION=pl_PL.UTF-8  LC_ALL=  

To reproduce this use: https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_tolocalestring, or create a file called index.html with the following contents:

<!DOCTYPE html>  <html>    <head>  <meta charset="UTF-8">      </head>    <body>      Hi!      <script>       console.log(new Date().toLocaleString())      </script>    </body>    </html>  

And then open this file using any value of LC_ALL and browser combination you care to try:

LC_ALL=el_GR.utf8 firefox index.html  

Then, look at the javascript console (usually available by pressing F12) and you will see the date format ignores the LC setting.

I also have en for language and pl for dates on a Windows machine and it works fine. Why can't Linux do this?

I was dealing with this for year now. All I can find in google is people with similar issue but without solution or problems with date format in system.

System: Linux Mint 20 Xfce

Why does using -F flag work while explicitly changing field separator by using FS variable not work when field seperator to be changed is '\t' in awk?

Posted: 26 Sep 2021 08:24 AM PDT

While experimenting with the Unix tool awk, I came across this subtlety which I couldn't explain. Suppose this is the file I am using as file.txt

Carl Gauss      1       Germany  Isaac Newton    2       England  Leonhard Euler  3       Switzerland  Donald Knuth    4       America  Alan Turing     5       England  Albert Einstein 6       Germany  

The columns are separated by a Tab. Now suppose I want to extract the first field in each row, so here are the two way I tried to approach this:

Test 1:

#!/bin/bash    awk -F'\t' '  {print $1;}  ' file.txt  

The output, as expected is:

Carl Gauss  Isaac Newton  Leonhard Euler  Donald Knuth  Alan Turing  Albert Einstein  

Now I tried another supposedly equivalent way to solve this problem:

Test 2:

#!/bin/bash    awk '  BEGIN {          FS='\t';  }  {print $1;}  ' file.txt  

The output which I got in this case was

C  I  L  D  A  A  

Only the first letters of the rows are being printed. As far as I know, both the methods should be equivalent but they are producing different outputs. I tried this out on different file.txt files created in different ways as well but I got the same result each time.

What is the explanation for this?

comparing and fetching words in two columns of different files

Posted: 26 Sep 2021 08:11 AM PDT

I want to compare two different columns of different files and fetch the common entries among them:

file1

abc             123    ttt    kkk   

file2

111 wed  222 kad  333 ttt  444 kkk  

I want to compare column 1 of file1 to column 2 of file2. If there are any common entries, I want to print the match lines from file2:

Expected result:

333 ttt  444 kkk  

I have tried below commands to fetch the result:

awk -F 'NR==FNR{c[$1$2]++;next};c[$1$2] > 0' file1 file2  

or

join -t -1 1 -2 2 -o 2.1,2.2 file1 file2  

but didn't get the expected results.

Terminal title not changed after ssh [closed]

Posted: 26 Sep 2021 07:27 AM PDT

I use debian in wsl2 and windows terminal, and I use openssh in debian as my primary ssh client, when I ssh from debian to remote machine, the windows terminal title changes acordingly, but now the terminal title become fixed. I tried to use openssh client from powershell in windows terminal, the termianl title can still changes acordingly.

I'd like to know why my terminal title didnot change when I ssh from wsl2 as before


I don't think the PS1 of the target machine matters, my PS1 setting is the same as when windows terminal can change title perfectly, and when I ssh from powershell (use windows termianl or stock powershell terminal) to the same machine, the title will change acording to the name of the machine

How to display who logged in or logged out in last x seconds or minutes?

Posted: 26 Sep 2021 10:17 AM PDT

I am trying to achieve this on bash on Ubuntu 20.04. Any available command?

How to restart Plasma 5 from terminal using nohup?

Posted: 26 Sep 2021 10:30 AM PDT

There are a lot of questions and answers about restarting Plasma 5. I realize that using KRunner is the best option, but today I could not access KRunner and had to use a terminal.

After reading Difference between nohup, disown and &, I felt like these two topics (restarting Plasma 5 and nohub/disown/background jobs) need to be combined into one answer specific to restarting KDE Plasma 5 the right way. Almost every answer I have seen about restarting Plasma 5 ignores the issue of nohup.

By following different answers about restarting Plasma 5, I have, at various times, found myself unable to close a terminal window without killing my newly started Plasma 5 session.

The following script is from a few answers, mostly https://unix.stackexchange.com/a/499373, and is modified to include nohup. Is this the definitive, comprehensive solution? Or is it a mess that needs to be avoided?

#!/bin/sh  kbuildsycoca5 # rebuilds the plasmashell database  timeout 5 kquitapp5 plasmashell #without timeout, it can hang for ~30-60 seconds  pgrep -U $USER -x plasmashell &>/dev/null && pkill -U $USER -x plasmashell  pgrep -U $USER -x plasmashell &>/dev/null && pkill -U $USER -x -9 plasmashell # here the process does not get to clean-up.  killall -9 plasmashell #sends a signal to all processes running any of the specified commands  pgrep -U $USER -x plasmashell &>/dev/null && echo "ERROR: cannot kill plasmashell"  nohup plasmashell &  

My specific question is about the last line:

nohup plasmashell &  

Is that correct in this context?

I don't know how to download and install Dissenter Browser on Ubuntu 20.04

Posted: 26 Sep 2021 07:32 AM PDT

I just installed ubuntu desktop 21.04 on my raspberry pi 4b. I want to switch from mozilla firefox, the default browser, to Dissenter. I am trying to download and install Dissenter Browser on my computer but I don't know how. I've looked into it, and I found that the version I've tried only works on amd64, but what I have is arm64. Can anyone help?

How can I transliterate some characters 1-to-1, leave some unchanged, and replace others with the same target character?

Posted: 26 Sep 2021 09:09 AM PDT

I have a file called file.txt containing:

MAL TIRRUEZF CR MAL RKZYIOL EX MAL OIY UAE RICF "MAL ACWALRM DYEUPLFWL CR ME DYEU MAIM UL IZL RKZZEKYFLF GH OHRMLZH"  

I'd like the characters replaced as follows:

M = T  A = H  L = E  C = O  R = F  E = I  X = S  (Any other letter) = _  (Anything else) = (itself)  

I have the fixed characters covered with:

tr MALCREX THEOFIS < file.txt  

Or:

sed 'y/MALCREX/THEOFIS/' < file.txt  

But how could I enforce the last two rules I mentioned?

Is it possible to combine two pointer xinput devices into a single device?

Posted: 26 Sep 2021 10:20 AM PDT

I'm using VirtualBox and it comes with a "Mouse Integration" feature, which creates a 2nd pointer input called VirtualBox mouse integration aside from the existing pointer input.

$ xinput  ⎡ Virtual core pointer                      id=2    [master pointer  (3)]  ⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]  ⎜   ↳ VirtualBox mouse integration              id=9    [slave  pointer  (2)]  ⎜   ↳ ImExPS/2 Generic Explorer Mouse           id=11   [slave  pointer  (2)]  ⎣ Virtual core keyboard                     id=3    [master keyboard (2)]      ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]      ↳ Power Button                              id=6    [slave  keyboard (3)]      ↳ Sleep Button                              id=7    [slave  keyboard (3)]      ↳ Video Bus                                 id=8    [slave  keyboard (3)]      ↳ AT Translated Set 2 keyboard              id=10   [slave  keyboard (3)]  

This thread has a lot more detail about this "multiple cursor inputs in VirtualBox" issue: Scrolling impossible while moving mouse - Fedora 28 VM guest on Win10

According to that thread, VirtualBox mouse integration receives only movement events while the other device only receives scroll events. As a result, scrolling does not work when the mouse is moving, as many programs only allow one active input device at a time.

Is it possible combine these two input devices into one "virtual" input device, so that desktop programs can use that device as the active input device?

Mouse input events can be checked with:

xinput test-xi2 --root  

On my machine it clearly shows mouse position and scroll events being sent by different devices:

EVENT type 17 (RawMotion)      device: 2 (9)      detail: 0      flags:       valuators:            0: 1704.97 (1704.97)            1: 39323.40 (39323.40)    EVENT type 6 (Motion)      device: 9 (9)      detail: 0      flags:       root: 55.23/570.23      event: 55.23/570.23      buttons:      modifiers: locked 0x10 latched 0 base 0 effective: 0x10      group: locked 0 latched 0 base 0 effective: 0      valuators:          0: 1704.97          1: 39323.40      windows: root 0x532 event 0x532 child 0x4600003  EVENT type 17 (RawMotion)      device: 2 (12)      detail: 0      flags:       valuators:            3: 15.00 (15.00)    EVENT type 6 (Motion)      device: 12 (12)      detail: 0      flags:       root: 55.23/571.23      event: 55.23/571.23      buttons:      modifiers: locked 0x10 latched 0 base 0 effective: 0x10      group: locked 0 latched 0 base 0 effective: 0      valuators:          3: -1470.00      windows: root 0x532 event 0x532 child 0x4600003  EVENT type 15 (RawButtonPress)      device: 2 (12)      detail: 5      flags: emulated      valuators:    EVENT type 4 (ButtonPress)      device: 12 (12)      detail: 5      flags: emulated      root: 55.23/571.23      event: 55.23/571.23      buttons:      modifiers: locked 0x10 latched 0 base 0 effective: 0x10      group: locked 0 latched 0 base 0 effective: 0      valuators:      windows: root 0x532 event 0x532 child 0x4600003  EVENT type 16 (RawButtonRelease)      device: 2 (12)      detail: 5      flags: emulated      valuators:    EVENT type 5 (ButtonRelease)      device: 12 (12)      detail: 5      flags: emulated      root: 55.23/571.23      event: 55.23/571.23      buttons: 5      modifiers: locked 0x10 latched 0 base 0 effective: 0x10      group: locked 0 latched 0 base 0 effective: 0      valuators:      windows: root 0x532 event 0x532 child 0x4600003  

How to install docker-engine in macOS without docker desktop?

Posted: 26 Sep 2021 09:08 AM PDT

Recently Docker announced that Docker Desktop would cease to be free for some kinds of users. See announcement in blog post.

I don't need any of the features that are exclusive to Docker Desktop®. I have used docker in a laptop with debian on it and that version is good enough for me.

Is there a way to install the linux version of docker in macOS? I need both the engine and the cli tool, nothing more. I run build commands, push, tag, run, docker-compose, etc.

libvirtd: No more available PCI slots

Posted: 26 Sep 2021 08:03 AM PDT

Ahoy. Today I wanted to set up a new virtual machine to manage my 8 hard disk devices.

Currently I use Fedora 31 as host, and Debian 9 as guest system. I want to pass through the block devices to the virtual machine, but unfortunately it doesn't work, and it's quite hard to find proper information without being a RedHat subscriber.

So what did I do? I try to attach the hard disk using, the following command.

virsh attach-disk Storage_ZFS_\(Debian\) /dev/sdb vdc  

Unfortunately I receive the following error.

error: Failed to attach disk  error: internal error: No more available PCI slots  

So what did I try? I did some research, and found something what has worked on SUSE, adding <controller type='pci' model='pcie-to-pci-bridge'/> somewhere in the VM's section, but unfortunately it didn't work as well. Only received the following error.

[root@millenium-fbe48 chairman]# virsh edit Storage_ZFS_\(Debian\)   error: internal error: Cannot automatically add a new PCI bus for a device with connect flags 800  Failed. Try again? [y,n,i,f,?]:   error: XML error: The PCI controller with index='0' must be model='pcie-root' for this machine type, but model='pcie-to-pci-bridge' was found instead  Failed. Try again? [y,n,i,f,?]:   error: XML error: The PCI controller with index='0' must be model='pcie-root' for this machine type, but model='pcie-to-pci-bridge' was found instead  Failed. Try again? [y,n,i,f,?]:   error: XML error: The PCI controller with index='0' must be model='pcie-root' for this machine type, but model='pcie-to-pci-bridge' was found instead  Failed. Try again? [y,n,i,f,?]:   error: XML error: The PCI controller with index='0' must be model='pcie-root' for this machine type, but model='pcie-to-pci-bridge' was found instead  Failed. Try again? [y,n,i,f,?]:   error: XML error: The PCI controller with index='0' must be model='pcie-root' for this machine type, but model='pcie-to-pci-bridge' was found instead  Failed. Try again? [y,n,i,f,?]:   

Does someone knows how to deal with it, and how to add the hard disks to my guest VM?

Convert this particular .bash_profile to .zprofile

Posted: 26 Sep 2021 09:20 AM PDT

I have this .bash_profile:

alias ip='ipconfig getifaddr en0'    PS1="\[\e[0;31m\]\$ \[\e[0;32m\]\w\[\e[0m\] : "  export NVM_DIR="$HOME/.nvm"  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  

and since MacOS updated to Catalina (https://support.apple.com/en-us/HT208050) zsh become the default terminal.

How can I convert this to a zsh .zprofile?

Using filter condition in python -mjson.tool command

Posted: 26 Sep 2021 09:03 AM PDT

Can I use a filter condition in python -mjson.tool command to select objects which has specific attributes?

For example, I have a sample.json file with for objects out of which two has an attribute "test": "pi". And I need to fetch only those two objects.

Using sed to replace numbers with '@' inserts '@' between every character

Posted: 26 Sep 2021 09:15 AM PDT

I want to replaced all number with '@' symbol. I am using the below sed command , but not getting the desired result.

command -

echo "abc 434 pankaj 444" | sed 's/[0-9]*/@/g'  

Result -

@a@b@c@ @ @p@a@n@k@a@j@ @  

how to send input from one script to another using bash script

Posted: 26 Sep 2021 10:00 AM PDT

I want to send input from one script to another through shell scripts

when I stop this script it display the message do u want to continue

$MAIN_SCRIPT_PATH/first.sh stop  

I am stopping the script using another script.I need to send yes to this script first.sh. How I will do this?

when stopping the first.sh it ask for user input. do you want to continue? I should send yes....

Why did installing vim-nox give python2 support instead of python3 support?

Posted: 26 Sep 2021 07:26 AM PDT

I try to install vim with python3 support. After a quick research, I learnt that vim-nox installs by default the python3 support. Except that, in my case, I have python2 support. The result of apt-get install vim-nox

Reading package lists...  Building dependency tree...  Reading state information...  The following packages were automatically installed and are no longer required:    ca-certificates-java coinor-libcbc3 coinor-libcgl1 coinor-libclp1    coinor-libcoinmp1 coinor-libcoinutils3 coinor-libosi1 default-jre    default-jre-headless firebird2.5-common firebird2.5-common-doc    firebird2.5-server-common fonts-opensymbol gir1.2-rb-3.0 gir1.2-secret-1    gir1.2-totem-1.0 hyphen-en-us java-common libabw-0.1-1 libatk-wrapper-java    libatk-wrapper-java-jni libcdr-0.1-1 libclucene-contribs1 libclucene-core1    libcmis-0.4-4 libe-book-0.1-1 libeot0 libetonyek-0.1-1 libexttextcat-2.0-0    libexttextcat-data libfbclient2 libfbembed2.5 libfreehand-0.1-1 libgconf2-4    libgltf-0.0-0 libgpod-common libgpod4 libhsqldb1.8.0-java libhyphen0    liblangtag-common liblangtag1 liblircclient0 libmspub-0.1-1 libmwaw-0.3-3    libmythes-1.2-0 libodfgen-0.1-1 liborcus-0.8-0 librhythmbox-core8 libsctp1    libsgutils2-2 libtotem0 libvisio-0.1-1 libwps-0.3-3 lksctp-tools lp-solve    media-player-info openjdk-7-jre openjdk-7-jre-headless python3-mako    python3-markupsafe rhythmbox-data totem-common tzdata-java uno-libs3 ure  Use 'apt-get autoremove' to remove them.  Suggested packages:    cscope vim-doc  The following NEW packages will be installed:    vim-nox  0 upgraded, 1 newly installed, 0 to remove and 60 not upgraded.  Need to get 0 B/1,049 kB of archives.  After this operation, 2,569 kB of additional disk space will be used.  Selecting previously unselected package vim-nox.  (Reading database ...   (Reading database ... 5%  (Reading database ... 10%  (Reading database ... 15%  (Reading database ... 20%  (Reading database ... 25%  (Reading database ... 30%  (Reading database ... 35%  (Reading database ... 40%  (Reading database ... 45%  (Reading database ... 50%  (Reading database ... 55%  (Reading database ... 60%  (Reading database ... 65%  (Reading database ... 70%  (Reading database ... 75%  (Reading database ... 80%  (Reading database ... 85%  (Reading database ... 90%  (Reading database ... 95%  (Reading database ... 100%  (Reading database ... 163905 files and directories currently installed.)  Preparing to unpack .../vim-nox_2%3a7.4.488-7+deb8u1_amd64.deb ...  Unpacking vim-nox (2:7.4.488-7+deb8u1) ...  Setting up vim-nox (2:7.4.488-7+deb8u1) ...  update-alternatives: using /usr/bin/vim.nox to provide /usr/bin/vim (vim) in auto mode  update-alternatives: using /usr/bin/vim.nox to provide /usr/bin/vimdiff (vimdiff) in auto mode  update-alternatives: using /usr/bin/vim.nox to provide /usr/bin/rvim (rvim) in auto mode  update-alternatives: using /usr/bin/vim.nox to provide /usr/bin/rview (rview) in auto mode  update-alternatives: using /usr/bin/vim.nox to provide /usr/bin/vi (vi) in auto mode  update-alternatives: using /usr/bin/vim.nox to provide /usr/bin/view (view) in auto mode  update-alternatives: using /usr/bin/vim.nox to provide /usr/bin/ex (ex) in auto mode  

The result of vim --version | grep python

+cryptv          +linebreak       +python          +viminfo  +cscope          +lispindent      -python3         +vreplace  Linking: gcc   -L. -Wl,-z,relro -L/home/pere/src/debian/ruby/ruby2.1/debian/lib   -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -fPIE -pie -Wl,-z,relro   -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl   -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector -L/usr/local/lib    -L/usr/lib/x86_64-linux-gnu/perl/5.20/CORE -lperl -ldl -lm -lpthread -lcrypt   -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil   -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions  -L/usr/lib/x86_64-linux-gnu   -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.1 -lpthread -lgmp -ldl -lcrypt -lm      

And the result of uname -a

Linux DM-debian 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux  

Get path of here document as a file

Posted: 26 Sep 2021 10:01 AM PDT

I have a program that takes input from an XML file whose path is specified as a parameter. I want my shell script to be self contained, so a here document seems like the right way to go. Unfortunately, this program doesn't accept input from STDIN, so piping wouldn't work.

I've read that here-docs are implemented as files in /tmp, so that leads me to think there might be a way.

Is there a way to inline my XML file within my shell script, and get a path for it that this xml parser could use?

dota 2 graphics problem in ubuntu 14.04

Posted: 26 Sep 2021 08:06 AM PDT

i installed ubuntu 14.04 in my laptop. then i installed steam and finally dota 2. but the graphics are very bad. i have amd raedon 7400 in my laptop. it seems like dota 2 is not running through my graphic card. i dont even know whether after installing ubuntu i have my graphic card driver installed or not. do i have to manually install the graphic card driver or it is already installed. and if so, how to enable it so that dota 2 runs with some good textures.

How to know if /dev/sdX is a connected USB or HDD?

Posted: 26 Sep 2021 10:42 AM PDT

How can I know if /dev/sdX is a local HDD or USB key?  I'd prefer a way of doing this without root privileges.

OK, udevadm helped a lot:

For local HDD:

udevadm info --query=all --name=sdb | grep ID_BUS  E: ID_BUS=ata  

For USB key:

udevadm info --query=all --name=sdc | grep ID_BUS  E: ID_BUS=usb  

Moving linux install to a new computer

Posted: 26 Sep 2021 08:45 AM PDT

I know that it can, in some circumstances, be difficult to move a Windows installation from one computer to another (physically move the hard drive), but how does that work on linux? Aren't most of the driver modules loaded at bootup? So theoretically would it be that much of a hassle?

Obviously xorg configs would change and proprietary ATI drivers and such would have to be recompiled (maybe?). Is there more to it than I'm thinking of?

Assume the 2 computers are from the same era, ie both i7s but slightly different hardware.

Update:
Thanks for the answers. This is mostly for my own curiosity. I have my linux system up and running at work, but eventually I'd like to move to a computer that I can get dual video cards into so I can run more than 2 monitors. But not any time soon

No comments:

Post a Comment