#unix

1 messages ยท Page 2 of 1

main olive
#

do

dapper musk
#

ah i got it in reverse

main olive
#

what about this

#

this is hex bytes right

#

is it possible to convert this to string

#

apparently xxd -r -p

dapper musk
#

yes

#

however those characters should be non printable at least according to question

main olive
#

yeah

#

they look like this

#

i am so confused ๐Ÿ˜ข

dapper musk
#

question asks you to find sequence of non printable non ASCII characters and then print it in HEX

dapper musk
#

or rather it is not it

#

because you do something strange with sort and uniq for some reason?

#

just do grep '[^[:ascii:]]' -o | xxd -p /dev/stdin ie find all non asci characters and conver them to HEX using xxd without printing line numbers

slate crypt
#

I'm getting this weird error when I try to update openssh on my rhel server. Any ideas on the cause?

โžœ  find /var/cache/dnf/ -name '*.rpm'                     
/var/cache/dnf/rhel-8-for-x86_64-baseos-rpms-ce63dfa6a7abcf7b/packages/openssh-server-8.0p1-13.el8.x86_64.rpm
โžœ  sudo find /var/cache/dnf/ -name '*.rpm' -exec rpm -U {} \;
error: unpacking of archive failed on file /etc/ssh/sshd_config: cpio: utime failed - Resource temporarily unavailable
error: openssh-server-8.0p1-13.el8.x86_64: install failed
error: openssh-server-8.0p1-10.el8.x86_64: erase skipped
#

I apparently cannot update the time of sshd_config?

# touch /etc/ssh/sshd_config
touch: setting times of '/etc/ssh/sshd_config': Operation not permitted
static silo
#

Thank you so much for answering! I'd love to use python since I'm way more comfortable with it compared to Bash, but I'm working on a Docker entrypoint script and I think it's best to just use Bash for that.

Anyway, I found a solution. I ended up not using subshells, so that I could use $! and it worked! Thanks again for your python example though ๐Ÿ™‚

formal schooner
#

subprocess.run should return a "completed process" object that includes a status code and i think a pid

#

!d subprocess.run

shy yokeBOT
#
subprocess.run(args, *, stdin=None, input=None, stdout=None, stderr=None, capture_output=False, shell=False, cwd=None, timeout=None, check=False, encoding=None, errors=None, ...)```
Run the command described by *args*. Wait for command to complete, then return a [`CompletedProcess`](https://docs.python.org/3/library/subprocess.html#subprocess.CompletedProcess "subprocess.CompletedProcess") instance.

The arguments shown above are merely the most common ones, described below in [Frequently Used Arguments](https://docs.python.org/3/library/subprocess.html#frequently-used-arguments) (hence the use of keyword-only notation in the abbreviated signature). The full function signature is largely the same as that of the [`Popen`](https://docs.python.org/3/library/subprocess.html#subprocess.Popen "subprocess.Popen") constructor - most of the arguments to this function are passed through to that interface. (*timeout*, *input*, *check*, and *capture\_output* are not.)
wise forge
formal schooner
peak badge
#

I'm using nvim with pyright. I have the following code:

class HologramResponse(BaseModel):
    success: bool
    limit: int
    size: int
    continues: bool
    links: Optional[dict]
    lastid: Optional[str]
    data: list
    
def fetch() -> None:
    response = requests.get(url, headers=headers)
    hologram_response = HologramResponse(**response)
    data = hologram_response.data
    lastid = hologram_response.lastid
    linkid_list = []
    month_list = []
    year_list = []
    sessions_list = []
    bytes_list = []
    for idx, value in enumerate(data):
        linkid_list.append(value.get('linkid'))
        month_list.append(value.get('month'))
        year_list.append(value.get('year'))
        sessions_list.append(value.get('session_count'))
        bytes_list.append(value.get('bytes'))
    ...

So pyright is telling me that I'm have an error (check picture attached) but the code runs perfectly and I do not understand why pyright is telling me that. Can someone explain me? This do not happens on VS code.

wise forge
#

And it says your code is wrong in terms of typing

#

In vscode that can happen too with correct installed plugins

peak badge
wise forge
peak badge
dapper musk
#

your enumerate is't corect

#

thats why it says tuple[int, Unknown]

#

because thats what enumerate returns

#

just do

for value in data:
  ...
peak badge
dapper musk
#

np

tulip dock
#

Is there a way to efficiently copy-on-write a file on Linux? Block by block, not copying the whole file on first write like overlayfs does?

#

Is there a tool to do that? If you're not running a filesystem with that capability already like btrfs or zfs

dapper musk
#

no COW needs to be implemented on filesystem level

tulip dock
#

It could be implemented as a virtual filesystem like aufs or overlayfs or unionfs-fuse

#

but they all seem to copy the whole file if you want to write to it

dapper musk
#

well that's defintion of COW

tulip dock
#

you could only copy the parts of the file that you change

dapper musk
#

thats ROW

#

not COW and thats why btrfs and ZFS do

#

most people just refer to it as COW

tulip dock
#

So there's no way to do this, you have to move the original file onto a new filesystem that has built-in support for this?

dapper musk
#

well you were right about that you can implement it as virtual filesystem however i cannot find anything that implements ROW

#

so unless you want to write 1 yourself then there is no other way

tulip dock
#

I don't think your terminology is right for COW/ROW though

#

I thought they were only distinctions on which copy is the read/write copy when doing snapshots

#

e.g. in Linux the COW you get from fork() or mmap() is called COW but it operates at the page level

#

btrfs, zfs, etc also refer to this as COW

#

Honestly it does sound like I should make one myself. It shouldn't be too hard with fuse, especially if I don't want to support every possible metadata operation... and if I can rely on sparse files

dapper musk
#

from my understanding COW copies data on 1st write an then operates on new data like PHP does. While ROW will redirect you to old data if you try to acces part of it that had't been modified after 1st write

tulip dock
#

I think the only tool that I could use to do this is devicemapper... e.g. turn my file into a /dev/loop0 and use devicemapper's built-in COW to make another device with COW

#

then I have a device, not a file, but that's close enough

main olive
#

How do i fix CERTIFICATE_VERIFY_FAILED error

#

most of the solution refer to running Cerificates.command
is there an alternative way to fix this

#

i installed python using macports

#

is this a macports issue?

shy igloo
#

maybe, I used the installer

#

/Applications/Python 3.10/Install_Certificates.command @main olive

#

that's where mine is

#

my cert installer

main olive
#

which install python in diff location

shy igloo
#

which python

main olive
#

/opt/local/bin/python

shy igloo
#

or your python launcher app

main olive
shy igloo
#

one sec

main olive
#

it just in appliation folder

main olive
shy igloo
#

okay

#

my mac

#

something like this

#

wait what

#

@main olive an app like that

shy igloo
#

in the filesystem

main olive
shy igloo
#

Install_Certificates.command

#

you are looking for that

#

or wait

#

do you have pip

main olive
main olive
shy igloo
#

@main olive do you have pip?

#

okay

#

run

#

pip install certifi

main olive
#

already did

#

in a venv

shy igloo
#

one sec

#

lemme send you my file

#

the cert installer

#

my mac is really slow

#

my python folder

shy yokeBOT
#

Hey @shy igloo!

It looks like you tried to attach file type(s) that we do not allow (.command). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

shy igloo
#

@main olive i'll dm it to you

#

python the bot stopped me

#

orrrrrr

#

not

#

okay i can't dm you

#

uhhh

#

one sec

#
#!/bin/sh

/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 << "EOF"

# install_certifi.py
#
# sample script to install or update a set of default Root Certificates
# for the ssl module.  Uses the certificates provided by the certifi package:
#       https://pypi.org/project/certifi/

import os
import os.path
import ssl
import stat
import subprocess
import sys

STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
             | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
             | stat.S_IROTH |                stat.S_IXOTH )

def main():
    openssl_dir, openssl_cafile = os.path.split(
        ssl.get_default_verify_paths().openssl_cafile)

    print(" -- pip install --upgrade certifi")
    subprocess.check_call([sys.executable,
        "-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])

    import certifi

    # change working directory to the default SSL directory
    os.chdir(openssl_dir)
    relpath_to_certifi_cafile = os.path.relpath(certifi.where())
    print(" -- removing any existing file or link")
    try:
        os.remove(openssl_cafile)
    except FileNotFoundError:
        pass
    print(" -- creating symlink to certifi certificate bundle")
    os.symlink(relpath_to_certifi_cafile, openssl_cafile)
    print(" -- setting permissions")
    os.chmod(openssl_cafile, STAT_0o775)
    print(" -- update complete")

if __name__ == '__main__':
    main()
EOF
#

copy that into a .command file

#

and run it

#

if that fails then switch from python macports to python official installer

#

bc i think the dir at the beginning references an executable that isn't there

main olive
#

didnt work
i'll make an ticket on macports support

shy igloo
#

switch the /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 for where your python is

#

@main olive try that first

main olive
#

how?

shy igloo
#

wait

#

imma make a python file for you

#

so you can just python it

#
# install_certifi.py
#
# sample script to install or update a set of default Root Certificates
# for the ssl module.  Uses the certificates provided by the certifi package:
#       https://pypi.org/project/certifi/

import os
import os.path
import ssl
import stat
import subprocess
import sys

STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
             | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
             | stat.S_IROTH |                stat.S_IXOTH )

def main():
    openssl_dir, openssl_cafile = os.path.split(
        ssl.get_default_verify_paths().openssl_cafile)

    print(" -- pip install --upgrade certifi")
    subprocess.check_call([sys.executable,
        "-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])

    import certifi

    # change working directory to the default SSL directory
    os.chdir(openssl_dir)
    relpath_to_certifi_cafile = os.path.relpath(certifi.where())
    print(" -- removing any existing file or link")
    try:
        os.remove(openssl_cafile)
    except FileNotFoundError:
        pass
    print(" -- creating symlink to certifi certificate bundle")
    os.symlink(relpath_to_certifi_cafile, openssl_cafile)
    print(" -- setting permissions")
    os.chmod(openssl_cafile, STAT_0o775)
    print(" -- update complete")

if __name__ == '__main__':
    main()
#

@main olive โฌ†๏ธ

#

copy that into a .py file

#

and python <file> it

#

i guess if that doesn't work you can check with macports support

main olive
shy igloo
#

okay you're welcome

left sinew
peak badge
left sinew
#

thank you

#

how to transfer theme to vscode

#

sorry i am new to these

left sinew
winged umbra
#

Hi pythonistas! Can anyone gather why this would give me duplicated output? ```import subprocess

Get a list of files in a directory

output = subprocess.run(("ls","../assets/"),capture_output=True, text=True)
for i in output.stdout.split('\n'):
print(i)

#

it prints the list of files twice...very bizarre

dapper musk
#

it does't?

winged umbra
#

This is so bizarre I'm wondering about my sanity. I rewrote it using os.scandir and am getting a similar result

dapper musk
#

can you post full command?

winged umbra
#

also```(my-env) bb@s76:~/wrk/game-reps/blaster-2d/triangle$ ls ../assets
b2d b2d.ldtk block1object.svg enemy1object.svg enemy2object.svg wand_object.svg
(my-env) bb@s76:~/wrk/game-reps/blaster-2d/triangle$

dapper musk
#

thats awfuly strange

#

try listing /

#

or some other folder

winged umbra
#

@dapper musk thank you for your help. I'm going to shut my box down and do something else I feel like I'm in a stephen king movie

#

I'll ping you on this later if I get an update

dapper musk
#

ok

winged umbra
#

@dapper musk Phew...not insane. I was importing a module called triangle while inside of a directory callled triangle

#

so it was importing itself .. ? ;P

#

wild but fixing the directory names solved it

dapper musk
#

oh i thought that importing itself would return an error

#

well apparently it does't

#
import main
print("test")

python3 main.py
test
test

#

well for some reason this works

winged umbra
#

very odd right?

#

saw nothing about it on the internet it was so corner case

brave bone
#

I'm using ssh to upgrade Python on a Raspberry PI running PI OS (Debian). I used sudo make altinstall and that is running right now. does this actually install the new version or is there an extra step to install it? The tutorial is not very clear

#

The tutorial says the next step is to delete the old link and then run this sudo ln -s /usr/local/bin/python3.10 python3 but that implies the new Python was installed?

#

nevermind, I found another tutorial which says that sudo make will install the new Python

#

Woo it worked! ```pi@raspberrypi:~/Python-3.10.7 $ python3.10 --version
Python 3.10.7

formal schooner
formal schooner
#

or at least python-build

winged umbra
formal schooner
#

i apparently missed the context then

#

usually these issues revolve around having the wrong cwd and not understanding how python searches for modules/packages

winged umbra
#

@formal schooner its good point you make. from sys.path it shows the cwd being the first place it looks for packages. The unexpected result that occurred for me is that the cwd had the same name as a different module I was importing for a location farther down on the list. very weird

formal schooner
#

yeah, python loads the first result it finds in sys.path

#

so if you have a globally installed module foo, as well as ./foo.py, and ./foo/__init__.py, import foo will find and load ./foo/__init__.py and completely ignore the others

#

other issues arise when people run python foo/a.py and don't understand why things behave differently different from python ./main.py or python -m foo.a

brave bone
formal schooner
wise forge
#

this solution is still horrible for any deployment though

#

like pyenv (which is advanced version of venv, but i dislike it for long deps resolving)

#

the real solution is to use docker containers ๐Ÿ™‚

#

they ensure all dependencies installed for applciation run (python packages / installed binaries to OS, whatever) and it would be still not polluting global OS system

#

each application can be having their own crap installed, without conflicting with others
and their old version would be easily wiped without a trace from system, when you deploy a newer version of them

brave bone
brave bone
formal schooner
brave bone
wise forge
#

minimal deployment final command: docker-compose up -d to deploy it, docker-compose logs to get its logs, docker-compose up to run without running in background
and no need to set any other multiple parameters like in regular docker

formal schooner
#

yeah i use docker compose even when i only have 1 image

#

podman supports it now too i think

#

i'm still using docker because pip caching with buildkit is awesome and i've read mixed reviews of podman support for buildkit

wise forge
#

i am tempted to migrate my dev environment to kubernetes one day. There are already made tools for that like tilt, dev spaces

#

but for now i am sufficiently satisfied with docker-compose too

brave bone
#

I'm running uvicorn through ssh, but the server closes when I end the ssh session. Any easy workaround for this?

#

Just a google lead would help

wise forge
#

technically there can be even easier solution than this, but they are more ugly and less intended way to have it. This way ensures to set auto restart of a service on reboot or when ended in errors, amd seeing its logs

brave bone
#

Thank you! I'm running ubuntu server

brave bone
# formal schooner you might want to try pyenv!

Is it normal to still need to use "python3.10" after setting 3.10 as local? ```bash
pi@raspberrypi:~/servers/test_fastapi $ echo "import sys;print(sys.version)" > main.py
pi@raspberrypi:~/servers/test_fastapi $ pyenv versions
system

  • 3.10.7 (set by PYENV_VERSION environment variable)
    pi@raspberrypi:~/servers/test_fastapi $ python main.py
    3.9.2 (default, Feb 28 2021, 17:03:44)
    [GCC 10.2.1 20210110]
    pi@raspberrypi:~/servers/test_fastapi $
#
pi@raspberrypi:~/servers/test_fastapi $ python3.10 main.py
3.10.7 (main, Sep 14 2022, 02:12:25) [GCC 10.2.1 20210110]
``` using the full command works
formal schooner
brave bone
#

I'll restart shell. I added all of the lines to .bashrc

formal schooner
#

eval "$(pyenv init -)" ; eval "$(pyenv init --paths)" or something like that

#

yeah you need to open a new shell for bashrc to take effect

brave bone
#

Ahh now it works! I had to restart the shell after installing the new version, thank you

formal schooner
brave bone
formal schooner
#

weird. you definitely shouldn't need to restart every time

brave bone
#

This is in my .bashrc ```bash
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

formal schooner
brave bone
#

It seems to working normally now, maybe I had previously entered "pyenv shell ..."

formal schooner
#

oh that's also possible

shy yokeBOT
#

:incoming_envelope: :ok_hand: applied mute to @supple hare until <t:1663175157:f> (10 minutes) (reason: burst rule: sent 8 messages in 10s).

The <@&831776746206265384> have been alerted for review.

eternal falcon
#

@supple hare spamming to try and get voice verification is a quick way to have another few weeks of voice mute. Please don't do that.

supple hare
#

my bad lol

#

๐Ÿ˜›

weak sorrel
#

I'm trying to set up an alias in Powershell to quickly startup a VM in VBox

#

Command to start a VM in VBox: vboxmanage startvm Fedora where Fedora is the VM name I wanna start

#

I tried Set-Alias -Name startfedora -Value vboxmanage startvm Fedora but it couldn't accept 'startvm' for some odd reason

#
Set-Alias : A positional parameter cannot be found that accepts argument 'startvm'.
At line:1 char:1
+ Set-Alias -Name startvbox -Value vboxmanage startvm Fedora
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-Alias], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetAliasCommand
fickle granite
#

sounds like you need some quote marks, there, Son

#

have you tried Set-Alias -Name startvbox -Value "vboxmanage startvm Fedora" or similar?

weak sorrel
#

one sec

#

It saved it but the shell doesn't recognize the value

#

gimme a min

#

It does work if I run it manually

#

This is what I got after I set startfedora alias

startfedora
startfedora : The term 'vboxmanage startvm Fedora' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ startfedora
+ ~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (vboxmanage startvm Fedora:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
#

But running vboxmanage startvm Fedora does work manually.

fickle granite
#

might want a function instead of an alias

weak sorrel
#

that make sense

#

is there such a thing as lambda function in powershell?

fickle granite
#

In bash, I never used aliases, and used functions isntead, for more or less this reason. Be funny if the same problem, with the same solution, is present in powershell

weak sorrel
#

hmm

fickle granite
#

try PS> help about_functions

weak sorrel
#

It worked!

fickle granite
#

huh

#

sorta surprised, tbh

weak sorrel
#

function Start-Fedora { vboxmanage startvm Fedora }

fickle granite
#

oh a function worked. That doesn't surprise me.

weak sorrel
#

function Stop-Fedora { vboxmanage controlvm Fedora poweroff }

fickle granite
#

use your power only for good

weak sorrel
#

๐Ÿ™‰

fickle granite
#

lookit you, following the naming conventions 'n' stuff ๐Ÿคฃ

#

looks around

#

I mean I know pwsh runs on Unix, but ...

weak sorrel
#

Hence why I asked here innit

fickle granite
#

surprised there isn't a #windows -- seriously there should be. Far more people use it, and it has its ... uh ... unique challenges

weak sorrel
#

I'm surprised not alot are asking WSL related questions

formal schooner
hallow herald
#

FYI for a linux guy

weak sorrel
#

It's literally Windows Subsystem for Linux

#

WSL has some weird issues vs Linux

tepid hare
#

Hello I was wondering if anyone can help me. Im trying to install python3-pip package on ubuntu and it does not work

#

anyone knows whats the problem?

#

no ubuntu

#

and do you know why is it doing?

#

it is corrupted

graceful mountain
#

Is there a better way to use entry-points with selinux rather than having to install as root?

#

I'm guessing not but figured it was worth seeing what other people had tried

formal schooner
formal schooner
graceful mountain
formal schooner
#

it looks like you need to create a new context for the executables in your home dir, e.g. semanage fcontext -a -t jahrules_user_bin_t /home/jahrules/.local/bin, and then set an allow rule for that

tepid hare
#

oh I aready solved it

#

i moved to fedora server much better

wet folio
#

Hi guys, I recently installed https://dbgbench.github.io/ tool. And I was trying to investigate some of their files for say find.07b941b1.report.txt in their repo to find few information like program, bugid, bug type, fault location, fault condition like this. Any suggestion what command I should use to find those information. I was using the run.sh in the docker dir but its not working for me. Any help regarding this. Thank you

frosty depot
wet folio
main olive
wise forge
#

if you will write through print, it will go to stdout (though u can specify in print as destination being to stderr too)
if you will use sys.stdout.write, it will go to stdout

#

if you will use raise Exception("text"), it will make tracelog to sderr

wise forge
weak sorrel
#

I'm trying to fiddle a log file to yank certain and text and write with yanked text. I understand there's a register in vim but I can't seem to figure out how to yank and assign to different registers. Is there something in docs for this? Hard to find.

shrewd stratus
#

"ay would yank to register a
"ap would paste from register a

weak sorrel
#

ah

#

thank you!

#

I've been doing "+y to save to system register and have that mapped to a vnoremap

#

I didn't know how it worked

shrewd stratus
#

:h registers should tell you more

weak sorrel
#

thank you!

weak sorrel
#

I can do this with a macro of searching and visually selecting, but I'm having trouble with :w to write the filename from the first yank

shrewd stratus
#

like, append to the register?

weak sorrel
#

Not append to the register

#

hmm

#

One min

shrewd stratus
#

swap?

weak sorrel
#

you mean a swap file?

shrewd stratus
#

no swapping register contents

weak sorrel
#

oh no. I wanna save the contents

#

One min

#
<xml>
...
</xml>

filename: blabla.log
#

I wanna copy all content between and including <xml> tags and save them to the filename blabla.log

weak sorrel
#

So I wanna save the many log files that its saving into multiple xml log files

#

Hope that make sense

#

I can do macro and visually copy between the xml tags and the filename. I'm just having trouble saving the content to the filenames mentioned in the same huge log file

#

Otherwise, I might try grepping but not sure how to grep multiple lines for the xml tags

weak sorrel
#

I gave up and just did the whole in Python.

#

My lack of bash/vim scripting has failed me

shrewd stratus
#

yeah, I don't think that's something you should be doing in Vimscript anyway

formal schooner
#

xml is the classic example of something that you cannot and should not try to parse using regex and other "context-free" string processing. you really do need a proper parser, unless you can make specific assumptions about the structure of the document.

#

so it's pretty easy to write a sed script to copy text between two lines, but once you have to start extracting information from the xml itself, you're struggling

#

@weak sorrel is this what you wanted?

#!/bin/sh

set -eu

input='test.xml'

output="$( sed -En '/filename: / s/filename: (.*)/\1/p' "$input" )"

sed -En '/<xml>/,/<\/xml>$/ p' "$input" > "$output"
prime cave
formal schooner
#

i also was just writing up an awk solution that does it in a single pass over the data

prime cave
#

what is , in /^<xml>/,/<\/xml>$/ p?

formal schooner
#

that's a range of patterns

prime cave
#

oh

formal schooner
#

oh the ^ probably doesn't need to be there

#

it's just pat1,pat2 ... meaning "apply ... to all lines starting at pat1 and ending at pat2, inclusive"

prime cave
#

ah multiple patterns

#

TIL

#

Wait, what if |?

formal schooner
#

you see it with numbers too, like sed -n '5,$ p' is equivalent to tail -n 5

formal schooner
prime cave
#

Couldn't we do multiple patterns with |? Is it better with , instead?

formal schooner
#

that's completely different

prime cave
#

I've not practiced with ,

formal schooner
#

a|b is one pattern that matches two things

#

a,b is two separate patterns

prime cave
#

oh

formal schooner
#

, isn't part of the regex pattern syntax. it's part of sed syntax

#

in regex syntax , is just a literal , character

prime cave
#

well thats why I didn't recognize it

#

I guess I need to brush up on my sed and awk

#

I might need them in the near future

formal schooner
#

very useful tools

#

nice little awk solution

#!/usr/bin/env -S awk -f

BEGIN {
  run = 0
  n = 0
  output = ""
}

/<xml>/ {
  run = 1
}

run > 0 {
  lines[n] = $0
  ++n
}

/<\/xml>/ {
  run = 0
}

/filename:/ {
  output=$2
}

END {
  if (output == "") {
    for (i = 0; i < n; ++i) {
      print lines[i]
    }
  } else {
    for (i = 0; i < n; ++i) {
      print lines[i] > output
    }
  }
}
#

it's only a single pass over the file, but it does require holding the entire output in memory until you find the filename at the bottom

#

the awk solution isn't much different from the equivalent python solution, just different syntax and the for line in sys.stdin is implied, not written out

prime cave
#

Nice. I'll play around with both some more until I'm more familiar

#

Thanks so much!

formal schooner
prime cave
#

I was told the same about awk too

formal schooner
#

fun story:

once when i was an intern, the team had received a data file from some tech people, but nobody on our team knew how to open the file (they were all excel users) which had the extension .dat, and the tech people weren't very responsive.

i had just recently started learning about unix tools, so i decided to try looking at the file with head and less, at least to visually inspect if it was "binary" or "text". it turns out that it was just pipe-delimited text data like col1 | col2 | col3. i ended up writing an awk script to clean it up, then i loaded it into R for further processing, and finally exported to an Excel book. i was treated like a hero for that!

woeful dome
#

What is a non-cursed way to check if something is a valid PCRE in python? (I'm guaranteed to be on Debian and have some normal packages).
I was able to do it by calling Popen(["grep", "-P", my_thing], ...) and seeing what error code it returns. But like, on a scale from 1 to cursed this is pretty cursed. Also not very fast.
I probably don't need it to be scientifically proven or whatever.

formal schooner
#

in hindsight, fuck you to whoever gave that dataset to my team without helping them open it and/or converting it to xlsx for them to use. but it was a great opportunity to apply all the stuff i had just learned, and to feel the raw sexy power of "the unix philosophy"!

formal schooner
prime cave
#

hmm makes me think about files from libreoffice with odt or whatever its called

woeful dome
#

Ah yes, ordinary differential tequations

formal schooner
#

i have no idea how the odt format is laid out, but it's probably not parseable as plain text. i know that docx, xlsx, etc. are some kind of weird XML/ZIP hybrid

woeful dome
formal schooner
#

nope i am pretty sure python uses its own separate regex engine and cpython knows nothing about libpcre

woeful dome
#

Like how sqlite uses btrees

formal schooner
#

for the most part i think python regex is a subset of pcre regex

#

not sure if it's a strict subset though

woeful dome
#

Yeah they're different

#

Maybe grep isn't that bad... And the program may be using grep in some cursed way already

formal schooner
#

oh dear are you doing some kind of input validation for a different program

#

i wonder if there's like an ABNF spec for PCRE somewhere that you can implement with Lark ๐Ÿ˜†

#

(subprocess doesn't look so bad by comparison)

woeful dome
#

Oh hold up @formal schooner, I can just call into libpcre2 with ctypes can't I

#

(""just"")

formal schooner
#
 pcre2_code *pcre2_compile(PCRE2_SPTR pattern, PCRE2_SIZE length, uint32_t options, int *errorcode, PCRE2_SIZE *erroroffset, pcre2_compile_context *ccontext); 

"just" indeed

woeful dome
#

Yeah lmao I'm working out this exact function right now

#

Segfaulting so far

shrewd stratus
#

how's that less cursed than calling out to grep? ๐Ÿ—ฟ

woeful dome
#

Should be faster innit?

formal schooner
#

how fast do you need it to be?

woeful dome
woeful dome
#

Ohh nice. The grep version takes about 1.5ms (as expected) while the ctypes version is only about 15us.

formal schooner
#

oh you got it working?

#

how did you end up doing it @woeful dome ?

woeful dome
#

Wdym how? Is there more than one way with ctypes?

#

I'm loading the libpcre2 library and then calling the pcre2_compile_32 function. If it returns a pattern, I'm just freeing it. Otherwise, I raise a Python exception with the error message

#

Also the error position is helpfully included unlike with grep which is just like: "you have an error in your regexp! where exactly? fuck you, that's where!"

formal schooner
#

i'm a little surprised that there isn't already a maintained libpcre binding library, but i guess it's usually not needed in python since python regex is close enough

native inlet
#

What is the default root logger?

#

For example, logging.info() logs a message to root logger, but I am not seeing it anywhere. I've checked syslog, messages, debug, etc.

shrewd stratus
#

it logs to stdout

#

the default level is WARNING IIRC

#

@native inlet

native inlet
#

Wait a minute.

#

2>&1 suppresses stdout, doesn't it?

shrewd stratus
#

no

native inlet
#

That would make a lot of sense why I don't see it.

#

Oh.

shrewd stratus
#

2>&1 redirects stderr to stdout

#

so you can see stuff written to stderr in stdout

shrewd stratus
native inlet
#

The real issue I'm facing is that if the default level is warning...why am I even logging it?

#

What I could do is set the level to be set at INFO, IF debug is True.

#

Because when it works as expected, I don't really need to see it. It's a CSV line that it puts out if it matches another file.

shrewd stratus
#

you could set it to DEBUG if debug else INFO

native inlet
#

I think that was the intention.

#

DEBUG would do INFO and then some?

shrewd stratus
#

yep it's the more verbose level

native inlet
#

I was just looking at this, thinking, "If only there were some place it was documented..."

#

At SetLevel() where it says it only logs at WARNING. ๐Ÿ˜„

#

Okay, thanks. Now that I know what's up, I'll finish doing this step.

shrewd stratus
#

by default, yeah

native inlet
#

It says the Level is unfulfilled.

shrewd stratus
#

try

logging.getLogger().setLevel(logging.DEBUG)
native inlet
#

Okay, that works and PyCharm is pulling information for each part of it. logging.info(str(line)) So, when this is called later, if debug == true, it'll automatically get stdout?

shrewd stratus
#

provided your original condition satisfies, yes

#

is debug a boolean or str?

native inlet
#

I convert it to a Boolean. I call it from a configuration file, so I have to convert it in the code.

#

I learned that the hard way.

#

So, to my code up there, I have to add debug = True.

shy yokeBOT
woeful dome
#

there is

#

but I don't want to add a dependency

#

also it's from 2015

formal schooner
#

and v0.7

woeful dome
#

I mean, maybe it still works

woeful dome
#

I just read the docs of libpcre2

formal schooner
#

i guess its just a matter of reading the docs, but figuring out all of whatever this is

 pcre2_code *pcre2_compile(PCRE2_SPTR pattern, PCRE2_SIZE length, uint32_t options, int *errorcode, PCRE2_SIZE *erroroffset, pcre2_compile_context *ccontext); 

and getting it to "not segfault"

woeful dome
#

thankfully I know how to use valgrind ๐Ÿ™‚

formal schooner
#

i definitely do not. i should learn maybe

woeful dome
#

wait let me get it in a moment

woeful dome
#

and it does magic segfault diagnostics

formal schooner
#

oh cool

woeful dome
#

like, valgrind python ass.py

formal schooner
#

i guess the assumption is that python itself shouldn't have memory leaks, so anything that does leak would come from calling c functions?

woeful dome
#

yeah

#

well it's not about memory leaks

#

basically, when it segfaults, valgrind shows you the stack trace

#

like, in which function it died

formal schooner
#

oh wow

woeful dome
#

I have done a bit of C so nothing complicated

formal schooner
woeful dome
#

yeah

#

there's a reason I don't enjoy C too much ๐Ÿ™‚

summer trail
#

That's a reason not to like ctypes, not a reason not to like C. The whole point of a typedef is to simplify things for the end user by aliasing type names. You're not supposed to need to unroll them, the compiler is supposed to do it for you

summer trail
#

you're facing that because ctypes deals with the library's ABI, rather than with its API, and typedefs are part of the API.

shrewd stratus
#

it prints them unescaped, which is why you get that behaviour

#

you can, for example, print the whitespace and newlines by passing -A

velvet estuary
#

I wrote a thread.
It works fine.
Also, i have try & except blocks for keyboard interruptions.
But still i see an error

#

The threading code:

#

The error:

shrewd stratus
spare glen
#

Does anyone know if its possible to use multiple cronjobs with different timezones?

wise forge
wise forge
#

Docker Deep Dive is good book to get started

#

makes easier to use celery beat too

#

u just have one docker compose, where one container is celery beat, another celery worker to process tasks, and preferably celery flower as monitoring system. And redis key-value as meesage broker (has queued tasks inside before they are processed)

#

So at least three processes, which would be looking much better in docker

wet folio
#
#!/bin/bash
total=0
find /root/Desktop/code -type f -name "*.[ch]" | while IFS= read -r file; do

    count=$(grep -c ^ < "$file")
    echo "$file has $count lines"
    total=$count
done
echo TOTAL LOC: $total

wet folio
shrewd stratus
wet folio
river raptor
#

does anyone know a good program for benchmarking in linux?

shrewd stratus
shrewd stratus
river raptor
wet folio
shrewd stratus
river raptor
#

thanks

#

because its cold for me and im on laptop and i need warm and i dont like gas prices

#

๐Ÿ‘

glad harness
#

heyo, i have a discord bot that im hosting on amazon aws. this question isnt related to discord bots though.
i want to make my python bot script run 24/7, and im using tmux for this. the problem is, when i run my script, the terminal becomes non interactive and im unable to detach from it to make it run 24/7. how should i solve this?

ember quiver
river raptor
#
sucukmitei@sucukmitei-S15447:~$ sudo mount -t ntfs /dev/sda1 /mnt/D
The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Falling back to read-only mount because the NTFS partition is in an
unsafe state. Please resume and shutdown Windows fully (no hibernation
or fast restarting.)
Could not mount read-write, trying read-only

can someone tell me why i cannot mount /dev/sda1? i need to mount it so it can be written

ember quiver
#

This is a drawback of NTFS in my experience, it will happen occasionally

#

Better to use a native Linux filesystem if you can and share to windows via smb or nfs

river raptor
#

@ember quiver what should i do

ember quiver
river raptor
ember quiver
river raptor
#

i found this on stack overflow i will try

#

okay it workd

#

thhanks dowcet

weak hill
# glad harness heyo, i have a discord bot that im hosting on amazon aws. this question isnt rel...

Hey.
Here's an an example service for systemd (name it mysrv.service, or anything but it has to have .service at the end):

[Unit]
Description=A service
After=network.target

[Service]
Restart=always
User=user
WorkingDirectory=/home/user/bin/user/
ExecStart="/home/user/bin/user/main.bin

[Install]
WantedBy=multi-user.target

And here's a shell script to place it to the right place and enable it (name it installsrv.sh):

# !/bin/bash

# $1 = service file name (without extension)

ln $1.service /etc/systemd/system # Create a link instead of copying here
systemctl enable $1

Example usage: ./installsrv.sh mysrv (If you used a different name for the file above, use that instead of mysrv)

After this you'll have to start the service: systemctl start mysrv (or restart to restart, stop to stop)

mystic sierra
#

anyone here has experience with vim?

fickle granite
#

a little

hidden pecan
#

I getting this error while installing packages

#

in arch linux

#

How can I solver this?

warped nimbus
#

Can your system connect to the internet?

#

Did you follow the installation steps to set up an internet connection?

hidden pecan
#

how do i check it

hidden pecan
#

how do i RESOLVE THIS

warped nimbus
hidden pecan
#

yup

#

everything working fine

#

now i was just going to setup custom kernel

#

for that I was installing some packages and now I getting just errors

warped nimbus
#

I don't have experience with setting up a custom kernel.

#

I would suggest you double check the configuration of your network manager

hidden pecan
#

sure

warped nimbus
#

And make sure your VM is set up to provide internet access

#

Make sure your network manager service is actually running

#

Could also be a firewall misconfiguration

native inlet
#

Anyone have tips for cleaner CLI formatting? Or is that something where as I write more scripts, I just do the same thing over and over again?

#

I've started putting like * [I] Information Goes Here for example.

fickle granite
#

do you mean, you want to know how to format your tool's output?

native inlet
#

That made me giggle at first because I am immature, but yes.

fickle granite
native inlet
#

How would you format doing like:

Now it's doing this
And also this
Oops! Have an error here!
But we can work around it```
fickle granite
#

well that's not particularly tabular, so I'd format that just as you've shown

#

what problem are you trying to solve by improving the formatting?

native inlet
#

Purely aesthetics.

fickle granite
#

gotcha

native inlet
#

When I run a lot of scripts, they just feel cleaner than that.

fickle granite
#

so copy their formatting ๐Ÿ™‚

native inlet
#

Maybe it's just that they picked a standard of output and stayed with it.

#

I didn't know if there was a document somewhere with standards or if it was made up.

fickle granite
#

you could use the logging library -- that won't make anything prettier, but it'll add timestamps and INFO and stuff

native inlet
#

Logging is a handy one to use. I like it.

fickle granite
#
>>> logging.info("See?")
2022-09-28T14:37:10+0000: [000000000018243] See?
>>> ```
native inlet
#

I'll take this all in.

tulip dock
#

Is there a smart way to setup sudo so it doesn't prompt me for passwords? Maybe a yes/no popup instead?

I don't want to enter my password when I type 'sudo' in a shell, but I don't want program to be able to use sudo without my noticing either

graceful mountain
#

In the sudo config you can setup using sudo with nopass

#

And you can configure it for only specific commands/users/groups

#

It's quite granular if you need it to be

fickle granite
#

yeah but does that prevent some random program from running "sudo"?

graceful mountain
#

Well no; but you can essentially use the config to permit certain sudo operations that aren't particularly dangerous for a program to run

wise forge
#

it will all dissapear with container deletion anyway. Your host OS will remain safe.

tulip dock
graceful mountain
tulip dock
#

yes but that doesn't include other terminals and it does include other processes in my terminal beside my shell

#

that's not what I want

graceful mountain
#

Convenience and security rarely go hand in hand.

tulip dock
#

I don't know if I believe that

#

I could get a Yubikey and have it enter the password when I press it. I sort of just want to skip the password step

#

it provides no security in this setup

fickle granite
#

why not open another window, and type "sudo -s" into it, and just use that when you feel the need ... the need for root?

graceful mountain
#

Do you actually need root that often that this matters?

#

Or is it an xy problem?

tulip dock
#

Just setting up my machine, just updated. This is one of the inefficiencies I'm trying to remove

graceful mountain
#

You know back in my day, sudo didn't exist and we liked it

#

Everyone just used root like real sysadmins

tulip dock
#

su -c was always a thing

graceful mountain
#

Anyway, I fail to see how an occasional password entry is an inefficiency for anyone with semi-competent typing skills

#

It's like 15 extra chars max

tulip dock
#

I found polkit which sounds promising. It knows how to ask my graphical session for a password. I don't know how to replace the password prompt with an ok/cancel though

graceful mountain
#

I'm pretty sure password prompts aren't meant to be bypassed

fickle granite
graceful mountain
#

Stage 1 Gentoo bootstrap install!

fickle granite
#

You try telling that to the younger generation ...

tulip dock
#

I setup full-disk encryption and enabled auto-login

#

I don't put passwords everywhere for fun, I have a threat-model in mind, that's how security works

#

I might just set NOPASSWD and forget about this, it's weird that there is no option though. Windows has a security prompt without a password, I thought Linux would be capable of it

graceful mountain
#

As if Windows were a good role model for adequate security?

tulip dock
#

that's no argument

dapper musk
dapper musk
#

you can also try appending

auth required pam_securetty.so
...
account required pam_securetty.so
...
session required pam_securetty.so

and try to make setuid wrapper that will just append tty to /etc/securetty and then set NOPASSWD on sudo

#

this will refuse authentication unless tty on which sudo is called is in this file

main olive
#

Who can help me with a Linux question

fickle granite
#

maybe me, if you post text instead of a photo ๐Ÿ™‚

main olive
#

Okay give me a few minutes

fickle granite
#

surely you're not typing it by hand?

main olive
#

No Iโ€™m taking a screenshot

fickle granite
#

uh

#

I don't want a screenshot; I want text

#

so that I can run it myself, without having to type it

main olive
#

How would I do that?

fickle granite
#

use the clipboard to copy the text from the console, or text editor, or wherever it is; then paste it into discord

main olive
#

Okay let me see if it lets me

#

#!/bin/bash
read -p "Enter the city name" city
for temp in Monday Tuesday Wednesday Thursday Friday Saturday Sunday
do
read -p "Enter the temperature of $temp" $temp
done
let Total = $Monday + $Tuesday+ $Wednesday+ $Thursday+ $Friday+ $Saturday +$Sunday
let Average = $Total/7
echo $Average

#

Like that?

fickle granite
#

yep, tx

main olive
#

Okay Iโ€™m just trying to get an average of all 7 days

#

It keeps saying the bottom 2 lines are wrong

fickle granite
#

here's what I see

#
(echo 10; echo 20; echo 30; echo 40; echo 50; echo 60; echo 70) | bash unix.sh 
unix.sh: line 7: let: =: syntax error: operand expected (error token is "=")
unix.sh: line 8: let: =: syntax error: operand expected (error token is "=")
#

is that what you're seeing?

main olive
#

Yeah

#

Idk what that means tho

#

Or how to fix it

formal schooner
#

i didn't even know bash had a let builtin

#

try Total=$(( $Monday + $Tuesday + ... ))$ instead (filling in the ... with the rest of the variables)

#

the $(( )) is "arithmetic expansion"

main olive
#

For which line?

#

And do I need to use let?

formal schooner
#

no i am saying you should consider using something else instead of let, because the syntax will be easier. the doc i linked has one option, and i just proposed another

fickle granite
#

and I am saying you should consider using something else instead of bash ๐Ÿ™‚

#

like, I dunno, I hear python is pretty nice

formal schooner
#

also valid. learning shell scripting is a useful skill though

#

this arguably is not a great use case for it

main olive
#

Well this is for a homework assignment

#

And Iโ€™m not sure how sciptting works

formal schooner
#

the power of shell scripts usually lies in the ability to seamlessly interoperate with files and text streams, and generally low syntactic overhead for managing background and child processes

formal schooner
#

admittedly there isn't a whole lot to understand. Bash is a computer program that reads lines of input, and performs certain operations based on the commands provided in the input

main olive
#

He hasnโ€™t taught us that

formal schooner
#

the input is a programming language

main olive
#

We only know about nano and pico

formal schooner
#

bash scripts are more or less the same as typing each line into the shell one after the other

#

don't think about it too hard

main olive
#

So if I do (( Monday + all the days)) that should fix the error?

formal schooner
main olive
#

So what are my other options if I donโ€™t use let?

formal schooner
#

if you want to use let, i think you just need to put quotes around the whole $Total = ... part

main olive
#

Oh let me try that

#

Yeah cuz let seems confusing

formal schooner
#

it looks like it expects each "expression" to be a single "word", which is shell script terminology for what we might consider a "string" in another programming language

main olive
#

But those should do the same thing or does let have a different purpose?

formal schooner
main olive
#

Got it let me try the other way Iโ€™ll let you know if it works

formal schooner
#

i suggest reading the page i posted earlier instead of guessing!

main olive
#

Where?

#

Wait nvm I see it thanks

main olive
#

Yeah it still doesnโ€™t work

#

Even if I remove let

#

Your post is a bit to advanced for me right now

#

Can anyone else help me a bit more?

formal schooner
#

let "Total = $Monday + ..."

#

did your instructor actually tell you to use let?

main olive
#

Iโ€™m putting โ€œTotalโ€ = $ โ€œMonday + Tuesday โ€ฆ sundayโ€)

#

Or is that not how you put it

formal schooner
#

no, the whole expression needs to be a single "word", so it all needs to be in the same pair of quotes

#

i demonstrated above

main olive
#

So it would be โ€œtotal = $monday+ $ tuesday โ€ฆ $ Sunday โ€œ

formal schooner
#

yes, try that

main olive
#

And same thing for average?

formal schooner
#

(keep in mind that Monday and monday are not the same thing)

main olive
#

Yeah the caps matters

formal schooner
#

basically let has its own mini programming language that you might say is "embedded" in the Bash language

main olive
#

Okay so no ( ) for either of them?

formal schooner
#

the (( was an alternative option, but it's probably best to keep working with the command you are already working with

main olive
#

Yeah I looked into let us really confusing

formal schooner
#

(( Total = $x + $y )) is the same as let "Total = $x + $y" -- note that the quotes are not necessary in the first version

#

and Total=$(( $x + $y )) is yet another equivalent way to do it (note there must not be spaces around = in this version)

main olive
#

Wow so thereโ€™s 3 different ways

formal schooner
#

let as far as i know was considered a design mistake and was quickly replaced with ((

#

this was in the Korn shell during the 80s, and Bash i guess adopted both let and ((

main olive
#

Okay I just tried this

#

#!/bin/bash
read -p "Enter the city name" city
for temp in Monday Tuesday Wednesday Thursday Friday Saturday Sunday
do
read -p "Enter the temperature of $temp" $temp
done
"Total = $Monday + $Tuesday + $Wednesday + $Thursday + $Friday + $Saturday + $Sunday"
"Average = $Total/7"
echo $Average

#

That gives me a different error now ๐Ÿ˜•

formal schooner
#

!code also, read below carefully for instructions on posting code with nice code formatting:

shy yokeBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

formal schooner
main olive
#

Wdym?

formal schooner
#

i think you are relying a bit too much on directly copying the text in my messages, rather than pausing to think through what i am telling you

formal schooner
main olive
#

Oh if you do โ€œ โ€œ you have to use let?

formal schooner
main olive
#

I thought you said let is same as (( ))

formal schooner
#

yes, but you didn't actually write let!

#

you wrote "Total = ..." but you needed to write let "Total = ..."

main olive
#

Oh I see

formal schooner
#

just writing "Total = ..." as the first word in the command line will cause the shell to try to run a command called "Total = ..." which probably doesn't exist on your system (or anyone's)

main olive
#

Got it that makes sense

formal schooner
#

@main olive i also just saw your question in the help channel

#

is that where you got the idea to use let?

main olive
#

No I was watching a YouTube video for loops

#

And they recommended using let

#

My professor doesnโ€™t really teach he just makes us read out of a book

formal schooner
#

i don't understand this obsession with watching YouTube videos for basic information that is probably in your book

#

it seems to be endemic among young people

#

the person making the video is pretty much just reading out of the book most of the time

main olive
#

The book didnโ€™t really explain the topic

#

Like I still have no idea what -p is used for

#

But I just know you need it

formal schooner
#

what book are you using?

main olive
#

The Linux command line by no starch press

formal schooner
#

it might be a good time to start practicing reading the actual manuals

#

Bash has an extensive manual documenting all of these commands

main olive
#

With man?

formal schooner
# main olive With man?

the man page for Bash in particular is hard to read and search through because it's all one big page and man doesn't have good support for sections, jumping to specific items, etc.

#

the read builtin command is documented on that page

#

and the -p option thereunder

#

this page is also a little annoying because it doesn't have html "anchors" that allow me to link directly to the command, but it's easier to read than the man page i think

main olive
#

That makes sense hmm also can you explain to me what | I know itโ€™s the pipe command I still donโ€™t know what it does.

formal schooner
#

does the book not explain it?

main olive
#

It does but I donโ€™t get it

formal schooner
#

what does the book say about it?

main olive
#

Iโ€™ve been really struggling with the point in piping 2 commands

#

It just gives examples of like ls | filename

formal schooner
#

a | b takes the output from command a and uses it as the input for command b

main olive
#

Can you give me an example with a command?

formal schooner
#

the name "pipe" is meant to evoke the process of connecting output to input with a pipe, like connecting a faucet to a bucket or something like that

main olive
#

So letโ€™s say ls | a file.

#

It just opens the file?

formal schooner
main olive
#

Hmm so when would you use it?

formal schooner
#

it's for connecting small programs in a "chain" or "pipeline" in order to perform more sophisticated processing tasks

main olive
#

But couldnโ€™t I just do them separately or no?

#

Is the whole point itโ€™s more convenient?

formal schooner
#

https://youtu.be/bKzonnwoR2I it might be elucidating to watch one of the actual creators of the pipe syntax talk about their origin!

Just what is a pipeline in the computer science sense? We asked Computer Science guru Professor Brian Kernighan

Why Asimov's Laws of Robotics Don't Work: https://youtu.be/7PKx3kS7f4A
Brian Kerninghan on Bell Labs: https://youtu.be/QFK6RG47bww
Don Knuth on Email: https://youtu.be/QS8qwMna8_o
Computer That Changed Everything: https://youtu.be/6...

โ–ถ Play video
main olive
#

Okay Iโ€™ll check it out

formal schooner
#

nowadays computers have a much larger amount of memory than they used to, so it's less important to avoid storing large chunks of text than it used to be

#

however the general paradigm remains extremely useful

#

https://youtu.be/tc4ROCJYbm0 here's another gem of a video with mr. kernighan talking about this stuff, back when it was all new

Watch new AT&T Archive films every Monday, Wednesday and Friday at http://techchannel.att.com/archives

In the late 1960s, Bell Laboratories computer scientists Dennis Ritchie and Ken Thompson started work on a project that was inspired by an operating system called Multics, a joint project of MIT, GE, and Bell Labs. The host and narrator of t...

โ–ถ Play video
main olive
#

Who is mr kernighan?

formal schooner
#

the person in the 1st video, and one of the original unix developers

main olive
#

Oh wow is he still alive?

formal schooner
#

skip to 6:00 in the 2nd video for the demo of pipes

main olive
#

I didnโ€™t know there was videos of the ones who created this stuff thatโ€™s so cool

formal schooner
#

yep most of the "OGs" are still alive, the oldest are in their 80s i think

main olive
#

Wow thatโ€™s insane also another quick question when doing if elif and else statements does indentations matter or no?

#

Cuz I know In python it does

formal schooner
main olive
#

Got it so I got it to work

#

๐Ÿ˜Ž

formal schooner
#

good!

main olive
#

Wait @formal schooner

#

I do need a bit more help if you got time

#

#!/bin/bash
read -p "Enter the city name" city
for temp in Monday Tuesday Wednesday Thursday Friday Saturday Sunday
do
read -p "Enter the temperature of $temp" $temp
done
((Total = $Monday + $Tuesday + $Wednesday + $Thursday + $Friday + $Saturday + $Sunday))
((Average = $Total/7))
echo $city $Total $Average
if [$Average -ge 80 ]; then
echo "Summer"
elif [$Average -lt 80]$$[$Average -gt 60]; then
echo "Winter"
else [$Average -le 60 ]$$[$Average -gt 50 ];
fi

#

Iโ€™m doing if else statements

#

I keep getting this error

#

./weather.sh: line 10: [96: command not found
./weather.sh: line 12: [96: command not found
./weather.sh: line 14: [96: command not found

formal schooner
#

also use [[ instead of [, the syntax is more flexible

main olive
#

Okay that helps let me see if that works

main olive
#

Wait @formal schooner || is or right?

formal schooner
main olive
#

helllooooo

#

can someone tell me what dose <<sudo -i >> do ?

formal schooner
graceful mountain
formal schooner
#

ah

pastel minnow
#

Hey everyone! Iโ€™m new here on the platform! Nice to meet you all

past ocean
#

hi

gentle vale
modern kestrel
#

Does anyone know how i coud strip a URL to extract part of it

#

If I wanted to take out racing or innovation

#

From URLs like that?

#

And return them as an environment variable to the parent script

untold socket
#

From there you can split on /

modern kestrel
#

ah sorry i need to use Bash for this @untold socket

dapper musk
#

echo url | awk -F โ€˜/โ€˜ โ€˜{print $6}โ€™ should work however i cannot test it now cause i am on mobile

formal schooner
#

@modern kestrel in addition to urllib, i really like the Hyperlink library

#

!pypi hyperlink

shy yokeBOT
formal schooner
#

oh, bash

#

not any good way to proceed there other than regex, or shelling out to a python or perl or awk script

#

it's best to avoid doing too much work in shell language imo. it's best used as glue between other programs

#

in this particular case you can do it with regex, so sed awk perl python whatever

#

but none of those are bash, they are all external programs

modern kestrel
formal schooner
#

if you have a particular constraint on your system, eg python isn't available, then state it

modern kestrel
#
URL=https://gitlab.com/stringa/stringb/racing/service

echo ${URL} | awk -F โ€˜/โ€˜ โ€˜{print $6}โ€™
modern kestrel
#

just curious trying to upskill my bash

formal schooner
formal schooner
modern kestrel
#

my bash honestly feels shocking its just gibberish to me at times

formal schooner
#

you can probably hack this together using several ${name%pattern} expansions

#

frankly bash is a nasty messy language to work with. it's only moderately better than posix sh

modern kestrel
#

but its so widely used

formal schooner
#

zsh is a huge improvement imo, but at that point you're getting dangerously close to "why not write it in python"?

modern kestrel
#

i just know i need to learn it at some point somehow everyone in industry is competent with it

formal schooner
#

yeah it's absolutely worth learning, but doing things like string processing in "pure bash" should be low on your list of learning priorities

#

i would instead focus on understanding different shell options, learning the different kinds of input an output re-directions, learning about job control, and understanding how to avoid pitfalls related to parameter expansion, word splitting, and quoting

#

and learning to use and love printf instead of echo

#

also arithmetic expansion!

#

all of those things imo are more useful and take precedence over trying to do string processing without the aid of an external program

dapper musk
formal schooner
#

also fair i guess

#

imo awk and sed are deceptively simple tools and probably deserve their own learning paths

#

for context, i love awk and i love that you used it as your solution

#

it's a shame that it gets relegated to one-liners, it's quite a nice little programming language on its own

modern kestrel
#

yeah, im actually a contractor and my primary strengths are aws and python so i do lean on those a lot but its a bit embarrassing when i ask colleagues for really simple things in bash if i need it, like i need to append an already really long script

#

im going to spend a lot of time this weekend and hopefully winter just getting better with it

formal schooner
#

some of my colleagues recently showed me a script they use that was clearly written by someone who was experienced with powershell and arrogantly assumed that bash worked the same as powershell

#

it was a mess

#

trust me that string processing was low on my list of "wtf" issues

modern kestrel
formal schooner
#

admittedly i haven't read that myself. i've just spent a lot of time working with shell scripting and have spent more time than i care to think about reading the manuals

#

i learned a bit of bash first, then i spent a long time learning zsh, and thereafter spent some time learning posix scripting for compatibility across systems. i still know zsh much better than i know bash.

#

wonder how i'd do on this certification ๐Ÿ˜†

modern kestrel
#

I use zsh in my terminal but i dont know it nearly well enough to understand the nuances

#

oh my zsh is all ive ever used

formal schooner
#

a book is usually good, however some books don't explain the "why" and just show lots of examples. that's not helpful

modern kestrel
#

yeah if you have any good book examples that would be good

#

LPIC is highly regarded but tbh its a little dry too

formal schooner
#

honestly i don't. what i used to do (when i had more free time and motivation to do such things) is browse the manual and focus on learning one section of it at a time.

#

so i'd look through it until i saw something that seemed like it'd be useful, then i read it in detail, and wrote some programs to practice using it

#

that, or i'd come across something in someone else's code or a stackoverflow answer or whatever, and do the same

#

you learn a lot that way, albeit gradually

modern kestrel
#

Yeah i wish i had that sort of time, i definitely think i need some structure to get through it effectively ๐Ÿ˜ฆ

#

Thanks anyway!

ember quiver
modern kestrel
#

This looks fun thanks! @ember quiver

modern kestrel
#

If you're moving a python script and some yaml files to a docker image wheres an appropriate place to put them in the filesystem? etc or usr/bin? or just the top level root

shrewd stratus
#

just make a /app directory or something and copy them in there

shell elbow
#

learning how applications communicate with kernel api

#

any recommended resources?

fickle granite
formal schooner
round elm
#

hi guys
im trying to host my website in a vps , i m connected with my vps using sftp
but when i type lls command it gives me this error psftp: unknown command "lls"
so any idea how can i fix it?

#

Bde#5vj%9ak0

dire cedar
#

Is there anyone available to help

broken forum
#

also depends on the time

ember quiver
ember quiver
# round elm hi guys im trying to host my website in a vps , i m connected with my vps using...

I've never used psftp but it's apparently not the same as normal sftp: https://superuser.com/questions/859789/how-do-i-print-the-contents-of-my-local-directory-in-psftp

zealous moth
#

heyy i cant move a folder from home to etc in kali
can anyone help me out

dapper hornet
#

and are you using sudo?

zealous moth
#

i was just drag dropping it

#

btw the problem was i was trying to drop it into the folder directly

#

so i had to open the destination folder in root first

river raptor
#

Will give more Disk Space (it will, but also will do something else(

ember quiver
#

BAD

river raptor
shrewd stratus
#

please delete your message
there are plenty beginners here who might try the command out

river raptor
#

ok

ember quiver
wise forge
#

...as long as first commands before that

docker run -it --rm ubuntu:20.04 sh

or

vagrant init ubuntu/focal64
vagrant up
vagrant ssh
brittle rock
#

This may be silly but I have a bunch of gzip data. When I unzip it using terminal or by clicking, it yields a unix executable. The actual data is supposed to be jsonlines. curious if anyone else has had this issue.

fickle granite
#

I wouldn't run that executable

#

just sayin'

quasi monolith
#

Hello there,
I've a grub issue :"minimal Bash like line editing is supported" on a dual boot win11- fedora 36
Someone deleted one partition yesterday, and nothing work ๐Ÿ˜ฌ

formal schooner
quasi monolith
ember quiver
quasi monolith
#

I solved it

fickle granite
#

gasp

#

excellent

#

presumably that means the partition wasn't really deleted?

quasi monolith
formal schooner
#

in english, UX usually stands for "user experience"

brittle rock
quasi monolith
loud pelican
#

Hi, I have a value ENV=DEV in .env file. I want to update it to ENV=TEST. I want to update it using terminal. Could anyone help me? Thanks in advance

#

I have to do it in my Bitbucket pipeline. So update has to be done in terminal.

ember quiver
unborn bramble
#

well, change it actually

onyx marsh
#

I've run a vps ubuntu 20. I was restarting my vps and it doesnt allow me to access through putty. When I check on my VPS system log. It ask me to log in. When I check on the qemu console. It said GRUB_FORCE_PARTUUID set, attempting initrdless boot.

#

The last thing I do on my vps was creating a new account to test the steamcmd on linux.

wise forge
#

and what do u use for virtualization exactly?

onyx marsh
#

KVM. I'm using Massive KVM from ramnode.

wise forge
onyx marsh
#

Ubuntu 20.04 LTS

wise forge
#

okay, from your nonsense answers i assume u a windows user ๐Ÿ™‚

wise forge
#

just install git bash, it has inside of it normal ssh / ssh-keygen inside as far as i remember

#

then u can pretty much generete if necessary ssh-keygen, RSA key and use its public key to create server, or connect by password if possible

#

ssh root@ip

#

optionally flag -i can provide some specific ssh-private key

#

it will make a more simple smooth experience

onyx marsh
#

I just notice there's an abuse report report toward my VPS :(. Someone brute force my vps throug vps and from the team just stop my vps.

wise forge
# onyx marsh I just notice there's an abuse report report toward my VPS :(. Someone brute for...

don't worry. That's pretty much normal... any cloud provider is constantly... bombarded with hack-scans.
For this reason people usually use ssh rsa ways only to connect and disable passwords
also for this reason they create servers only in private networks, that have cloud level firewalls that expose only necessary ports for services... (this feature is not available for too simple providers)

wise forge
zinc juniper
glad bridge
#

(Fedora)

#

Anyone know what services they are and how to disable them so they dont start on boot

dapper musk
#

i am not sure about 1st howver
2nd is dbus ie service for inter process cominication
3rd pulseaudio-pipewire it is emulation of โ€œoldโ€ audio system running on top of
4th service pipewire it is used for audio/video
5th is gnugpg it is used for cryptography

#

you shouldnโ€™t disable any of those

modern kestrel
#

Guys, does anyone know how i can point a command to a script which then executes the true command?

#

for example i want to redirect ls to a script which runs ls then another command

#

but i still want to use ls as the command

prime magnet
#

I think you can do bash -i wrapper-script.sh command. I'm not 100% sure but I think that's how I solve entrypoints with extra level in Docker

wise forge
#

requirements are unclear

#

get examples

formal schooner
#

if you want to replace an existing command, write a shell function

#

e.g. in bash

function ls() {
    printf 'I am executing the "ls" command!\n'
    command ls "$@"
}

ls -lA .
#

the function with override the ls "command", then you run the real command with the command builtin, which bypasses functions

#

note that command is not "portable" across POSIX shells, but it's available in Dash, Bash, Ksh, and Zsh which covers pretty much any shell you'd find outside of a retrocomputing museum or a Busybox environment

river raptor
#

i have a question, when doing sudo apt update, how do i remove these warnings and errors?

ember quiver
# river raptor i have a question, when doing sudo apt update, how do i remove these warnings an...

You've got multiple things going on there and you may need to address them separately. I would start here: https://askubuntu.com/questions/1403556/key-is-stored-in-legacy-trusted-gpg-keyring-after-ubuntu-22-04-update

olive rain
#

What is Unix?

main olive
#

google

drifting rune
ember quiver
drifting rune
drifting rune
#

thanks for your helping โค๏ธ

river raptor
#

when i set up my linux, i set the language to german, now i changed it to english, can i change the [J/n] to [Y/n]?

desert karma
#
fickle granite
#

I'd sign up for AWS or Azure, and I think they give you a little machine for free for a month or something.

#

I wouldn't begin to trust some random site I'd never heard of.

#

linode is probably OK

#

oracle and salesforce too

opaque ginkgo
#

SEO spam in the embed
clearly a trustworthy site

small stag
#

Is MacOS a good OS for programming in Python? Or programming in general?

fickle granite
#

yes.

#

I've used nothing else for almost ten years, and wish I'd switched sooner.

small stag
#

๐Ÿ‘

wise forge
# small stag Is MacOS a good OS for programming in Python? Or programming in general?

i would disagree with person above. Person above is Apple cult fanatic if he says so. Apple is good only for programming applications intended for IoS/Swift
For python it is the best to use Linux xD Rich development friendly open source ecosystem. No problems with CPU architecture, like u will have with Mac(Mac has arm64, while all servers and all other users Windows/Linux usually run on amd64). Free.
Linux is best if your target plaform is Linux servers/Linux desktop stuff. Which is for all python application essentially (be it Web dev or DS)
Linux can run containers (needed for Web at least) without virtualization shenanigans under the hood for secondary OS (like it happens with Windows/Mac)
Linux owner owns his OS fully and can do everything, best security xD U can increase your RAM memory through stuff like zRAM compressing data in section of RAM
Making yourself depended on propietary expensive solution is just silly. It has less support than Linux for development purposes. Only Linux supported first for all dev web tools

small stag
#

The thing is MacOS has much more available programs & apps. While Linux is good for programming, I believe thatโ€™s it? And most importantly, MS Office

wise forge
#

Also using Linux, u a making sure that your app is better developed/tested, less effort it made for deployment to Linux servers. It falls under DevOps Twelve Factor App 10nth rule about dev/prod parity https://12factor.net/dev-prod-parity

wise forge
# small stag The thing is MacOS has much more available programs & apps. While Linux is good ...

Perhaps do u mean that u will be forced to use programs like Safari Browser, which is more buggy laggi proprietary solution?
Internet explorer of Apple ecosystem, equivalent to how it was in Windows.
Microsoft eventually gave up this race and just uses Chrome engine (Blink) (Open source developed under direct Google control) under the hood in order to solve all rendering problems in its web browser Edge
There is a certain reason why Chrome dominates more than 70% of a market, while the rest percentage is some kind of Chromium forks xD

#

Exclusiveness of Apple stuff is just an illusion.

#

surely nice of them creating at least some competion to Google, which kind of already monopolized almost browser market though

wise forge
#

to each his own opinion. Same thing i think about Windows. Windows is great only for development for Windows. Well, and certainly better access to games in Windows.

#

i am quite deep into web development, including wielding infrastructure as a code instruments for that. Only Linux can satisfy my needs for that.

#

it is wrong opinion when it comes for development for Linux as target platform (which it is in 95% cases in terms of web development). It is so at least according to Twelve factor app and DevOps engineering

#

it is quite obvious, that best development for Linux is made from Linux

#

https://betanews.com/2022/10/02/spotify-is-forcibly-installing-on-windows-10-and-windows-11-systems/ what can be worse than proprietary systems making decisions for you? xD

If you have noticed the appearance of the Spotify app on your computer but you don't recall installing it, you are not alone. There are multiple reports -- or complaints, even -- from users of Windows 10 and Windows 11 that the app has installed itself without permission.

#

Sure. That's why we use Managed deployments like AWS ECS or Managed Kubernetes Clusters
Turning the problem of security of individual OSes almost completely delegated to cloud provider, or turning security problems to... more centralized controlling issue

#

Nevertheless it again becomes Linux to run it... Because it is scalable from being free (and from minimal overhead), and from completely being configurable (as u mentioned) to be turned secure. And the most importantly in comparison to other OSes it is easly automated in its configurations. That's the most important part too

#

Linux can be easily stripped to almost zero, to make smaller possible attack surfaces

#

Shrugs. It is more convenient to run dev env on current machine, then accessing it with virtualization/remote accesses.
Makes less complicated instructions invokable directly from current machine
And less performance load to machine / less networking delays
Plus running Linux as your OS, u get full access to its full priveleges, like increasing ram through zRAM xD, or easily ability to launch its GUI parts if necessary
Also it is more secure to leave your PC at work / other places, when u know it its file system is completely encrypted with LUKS (which is turned in one checkbox during linux installations) xD

#

They aren't disadvantaged when they don't deal with development for Linux. They are disadvantaged when they are developing for Linux.
Developing for Linux makes software immediately tuned it for that, less development hassle to tune stuff.

#

Easy. Developer in frontend framework React.js, developed his stuff in Windows. His javascript library imports were case insensitive in Windows due to its case insensitive file system. When we tried to compile it for Linux, it immediately failed because of this reason. (extra capital letter where it was not needed)

#

Same problem with also compiling any stuff essentially, or having software that uses OS internal features (including its things how its filesystem works)

#

This problem is moderately low for interpreting language, but than lower to hardware you go, then more troublesome it will become

#

All right. Software in Linux including Python has more parallelism options ;b in Linux multiprocessing through fork is available, while in Windows it is not.

#

Small differences one by one, make difference

#

i say that multiprocessing through function called fork is not working on Windows

main olive
#
        // Windows Subsystem for Linux (WSL) - previously Bash on Windows
        // - Example: `C:\\Windows\\System32\\wsl.exe`
        //
        // Git-bash on Windows
        // - Example: `C:\\Program Files\\Git\\bin\\bash.exe`
        //
        // Cygwin
        // - Example: `C:\\cygwin64\\bin\\bash.exe`

which of these is the least miserable to use? ||i could also try learning powershell||

dapper musk
#

you can use powershell in linux

#

wsl is overall the best because it is just VM and thus offers best compatibilty. not everything runs on cygwin and git bash

main olive
#

How can I do this?
Modify the executable.sh file again, add the command for it to create the following directories upon execution.

main olive
#

thanks for the thoughts went with wsl ThumbsUp

fickle granite
#

very diplomatically phrased, Sir/Ma'am

fickle granite
ionic burrow
#

Have a nice day everyone! I was trying write sh file for installing. I did create virtualenv. But ฤฑ can't access this. These the codes ```py
python3 -m venv venv
source ./venv/bin/activate

I get the err
```code 
install.sh: 5: source: not found
``` How can ฤฑ fix this
wary hazel
ionic burrow
wary hazel
#

Are you running the script manually or is something running it automatically? And what operating system are you using?

main olive
#

Guys i need help in an exercise
is there any way somone can help?

fickle granite
#

ask in a help channel

gloomy lava
#

Is there a way to set a permanent $PYTHONPATH while being in a Conda environment?

fickle granite
#

on UNix, I'd expect this to work

$ PYTHONPATH=/path/to/python conda
wise forge
#

when project is built into docker, permament ENV can be defined at Dockerfile level as ENV var

gloomy lava
cobalt saddle
#

how to get env variables?Python-dotenv could not parse statement starting at line 1

fickle granite
cobalt saddle
fickle granite
#

?

#

Currently available help channel(s): help-cherries, help-avocado, help-pear

wise forge
cobalt saddle
gloomy lava
wise forge
#

they will be recognized as packages without PYTHONPATH hacks then

sonic zephyr
#

Hii guys I need help on something..So is there any way I can use CURL to not completely download the html page but till the I find this particular phrase..suppose I have a page with app I'd and its status..so instead of loading the whole page if it finds this app I'd and its status I want the curl to terminate...I am having a problem because sometimes curl takes a lot of time return the html page so I want to a way to hack a way around

wise forge
#

u a wishing only partially rendered output to stdout perhaps instead of partial download

#

anyway, doing partial http request download is black magic of very low level... not really feasable put amount of effort for low gain. It requires super high level if it is possible.

sonic zephyr
wise forge
wise forge
# sonic zephyr Okay thanks.. I have a yarn and spark running and sometimes a job is shown comp...
  1. Anyway, i would have tried finding solution, how to change request to your Spark in the way that it sould be reporting only job status
  2. If u need to see those statuses only manually, then perhaps u are missing some observability (monitoring/logging) solution which would have showed in some nice interface this stuff (technically automatable too to extract this info with script out of monitoring solution though)
raven prism
#

Has anyone programmed a drone with python? If so can you please tell me what drone you ordered

raw moss
#

Hi all, is there a chance to get link for ubuntu discord server ?thanks

raw moss
main olive
#

Arch Linux + KDE Plasma
rc=-1908 error code
this happened to me the other time and idk how i fixed it
does anyone know the solution to this? installed virtualbox from the AUR

formal schooner
main olive
#

I'm assuming you followed the instructions in the error message already...