#unix

1 messages · Page 46 of 1

main olive
#

try os.system("cls")

main olive
#

Hello,

Does someone know how to really clean a terminal? Not using the clean command which only put previous results out of the screen, but deleting them from the terminal. It's tedious when debugging with programs with long output not be sure you're looking at the latest attempt. I've seen reset but id does nothing for me (mac OS)
@frank coral how does tput clear work in macos?

#

tput is in ncurses-utils if it isn't installed by default

frank coral
#

tput clear has the same effect as clear for me

main olive
#

ah ok

warped badge
#

Heyo, i'm having issues getting pyenv on my vps

#

i have 1 account that has pyenv

#

then i tried installing it on a new user, and when i did exactly the same it just says "pyenv not found, did you mean: bla bla bla"

#

so like it is installed on root

#

it is installed on 1 acocunt

#

but on the other one it just will not install

#

i'm on ubuntu btw

#

i just created the user too, so it's a clean install

formal schooner
#

@warped badge list the commands you used to install pyenv

warped badge
#

it already works now i do believe

#

i just deleted the user and restarted and now it works

olive jungle
#

Hi, I'm trying to execute a Python program using the IPython interpreter.
Most recently I ran the program here and got a lengthy output: https://hatebin.com/yyhkmhrkqz
I can't understand it.

hollow venture
#

Hi, I'm trying to execute a Python program using the IPython interpreter.
Most recently I ran the program here and got a lengthy output: https://hatebin.com/yyhkmhrkqz
I can't understand it.
@olive jungle sounds like you need to install pyqt5 (or another Qt lib)

#

what OS/distro are you on?

olive jungle
#

@hollow venture Kali Linux
how do i install pyqt5 (or whatever lib works best here)?

hollow venture
#

You know how to install packages on kali?

#

If so, just install pyqt5

#

maybe apt install pyqt5 ? I haven't used it in ages, so not sure.

olive jungle
summer trail
#

@olive jungle what do you get when you run this?

python3 -c 'import PyQt5'
olive jungle
#

@summer trail nothing

summer trail
#

then PyQt5 is installed, and you're able to import it successfully.

olive jungle
#

how do i do that?

olive jungle
#

@summer trail hey can you peek at #data-science-and-ml and see what we've been trying? we are not doing well.

crimson compass
#

Hi, I'm trying to execute a Python program using the IPython interpreter.
Most recently I ran the program here and got a lengthy output: https://hatebin.com/yyhkmhrkqz
I can't understand it.
@olive jungle is this code being run in a vps ?

#

Or ssh ? Seems to be xdispay not set ( no gui)

olive jungle
#

@crimson compass WSL

#

but i'm remoted in

#

so i have a desktop enviroment gui and so on

#

using rdp

#

using the xrdp service

crimson compass
#

Yes that's the issue there :)

#

If you run you script from a terminal within the rdp it should work

olive jungle
#

it does not work that way

#

i would only test a visualization tool within the rdp environment and nowhere else

crimson compass
#

Oh My! Then you have bigger issues :p
Didnt use WSL but I'm trying to understand
I'm sure its X related error

olive jungle
#

@crimson compass you can check what has been tried by looking at #data-science-and-ml we've been struggling there for a few hours

crimson compass
#

Okey 1 sec

olive jungle
#

ty

crimson compass
#

Did you launch venv as a module ? Of python
python3 -m venv -p python3 .

olive jungle
#

@crimson compass I followed the instructions and documented all i did

#

i can perform whatever commands you need

#

i'm not sure honestly

#

sorry

crimson compass
#

Ok to initiate the venv correctly we should call it from within pythob

#

Try these

#

python3 -m virtualenv -p python3 .
Or
python3 -m venv -p python3 .

olive jungle
#

@crimson compass

crimson compass
#

sudo apt install python-virtualenv

olive jungle
#

/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17
❯ sudo apt install python-virtualenv
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python-virtualenv is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-virtualenv' has no installation candidate

#

@crimson compass u get that?

crimson compass
#

Yep in kali the package is python3-venv

#

My bad

olive jungle
#

unable to be located

#

wait nvm i located it

#

done @crimson compass

#

sudo apt install python3-virtualenv

crimson compass
#

python3 -m venv .

#

Not the "." Means your venving the current directory

olive jungle
#

x INT

#

i'm not sure if it completed...

#

i didn't get output

crimson compass
#

Can you share a screenshot

olive jungle
crimson compass
#

source bin/activate

olive jungle
#

done

crimson compass
#

Screenshot please

#

@olive jungle

olive jungle
crimson compass
#

pip install ipython

#

Run this now

olive jungle
#

not pip install ipython3?

crimson compass
#

And then you should be done with ipython

#

pip is ---> pip3

olive jungle
#

in the past

#

ipython = 2.7

#

but i want 3.8

#

ah ok

#

jas

crimson compass
#

It's for py3

#

All good ?

olive jungle
#

didn't work

crimson compass
#

What was the error

olive jungle
crimson compass
#

A screenshot would help troubleshoot

olive jungle
#

this should help a lot

crimson compass
#

Line 18 syntax error

#

Line 11 is weird

#

You should run it with ipython

#

Not ipython3

olive jungle
#

i did both for your information

crimson compass
#

Yep I've seen it

#

Abd the weird thing is it is still accessing /usr/lib/packages :/

#

Try this

#

deactivate

olive jungle
#

deactivate

#

?

crimson compass
#

Yes run deactivate

#

And then run
python3 -m venv --no-site-packages .

olive jungle
#

i'm using zsh

#

maybe this command is invalid for it?

#

it did nothing

crimson compass
#

Ok

#

Run this plz

#

python3 -m venv --no-site-packages .

olive jungle
#

/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17
❯ python3 -m venv --no-site-packages .
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear] [--upgrade] [--without-pip]
[--prompt PROMPT]
ENV_DIR [ENV_DIR ...]
venv: error: unrecognized arguments: --no-site-packages

/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17

crimson compass
#

virtualenv

#

Can you run that ?

olive jungle
#

❯ virtualenv
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--app-data APP_DATA] [--clear-app-data] [--discovery {builtin}] [-p py] [--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed]
[--activators comma_sep_list] [--clear] [--system-site-packages] [--symlinks | --copies] [--download | --no-download] [--extra-search-dir d [d ...]] [--distro version] [--distlib version] [--msgpack version]
[--lockfile version] [--setuptools version] [--pytoml version] [--retrying version] [--requests version] [--pkg_resources version] [--pep517 version] [--chardet version] [--webencodings version] [--idna version]
[--CacheControl version] [--ipaddr version] [--certifi version] [--urllib3 version] [--wheel version] [--appdirs version] [--packaging version] [--html5lib version] [--six version] [--pip version] [--colorama version]
[--progress version] [--pyparsing version] [--contextlib2 version] [--no-distro] [--no-distlib] [--no-msgpack] [--no-lockfile] [--no-setuptools] [--no-pytoml] [--no-retrying] [--no-requests] [--no-pkg_resources]
[--no-pep517] [--no-chardet] [--no-webencodings] [--no-idna] [--no-CacheControl] [--no-ipaddr] [--no-certifi] [--no-urllib3] [--no-wheel] [--no-appdirs] [--no-packaging] [--no-html5lib] [--no-six] [--no-pip]
[--no-colorama] [--no-progress] [--no-pyparsing] [--no-contextlib2] [--symlink-app-data] [--prompt prompt] [-h]
dest
virtualenv: error: the following arguments are required: dest

/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17

crimson compass
#

Great

olive jungle
#

it says something else is required 😦

crimson compass
#

Yeh one second

#

unset PYTHONPATH

#

python3 -m venv .

#

And then
source bin/activate

olive jungle
#

is this a command? unset PYTHONPATH sorry i can't tell

crimson compass
#

Yep

olive jungle
#

k

#

running them in the order you presented

crimson compass
#

Good

#

Tell me when you done

olive jungle
#

done

crimson compass
#

Know we will check if your venv is isolated

#

Run these two commands

#

whereis ipython

#

And then just run
ipython

#

And let me know of the output

olive jungle
crimson compass
#

Good

olive jungle
#

it seems odd that there's ipython located in the paul deitel folder

crimson compass
#

Can you run your script now

olive jungle
#

that's just a storage dir for python lessions

#

let's see

crimson compass
#

Yes that's the venv we've created

olive jungle
#

can i move the venv out later?

#

also it didn't work posting screen in a sec

crimson compass
#

Yes for the venv you can delete it and create it elsewhere

olive jungle
crimson compass
#

Do you have a requirements.txt in that folder ?

olive jungle
#

no

crimson compass
#

( otherwise we will get dependencies one by one )

#

Hhhh ok let's go than

#

pip install matplotlib

#

It would be easier if you share the import section w

#

Of the script

#

We will guess the required packages

olive jungle
#

i'm just a beginner but beginning is hard

crimson compass
#

And then you can put them in a txt file and name it requirements.txt

#

i'm just a beginner but beginning is hard
@olive jungle nah you're fine , keep going

#

( phone keyboard is laggy )

#

Always keep in mind to store the required packages in a single txt file

olive jungle
#

first command complete

crimson compass
#

And then you can just run
pip install -r file.txt

#

Will get all dependencies mentioned in the file ;)

olive jungle
#

ty

crimson compass
#

Ok rerun your script

olive jungle
#

(my instructor never mentioned seaborn lol)

crimson compass
#

pip install seaborn

#

Can you share the import section of the script

olive jungle
#

sure also i just wanna remind u i intend to use ipython for like 16 lessons lol

#

do i have to do this x16?

#

cause that would suck

crimson compass
#

Nope

olive jungle
#

ok good

crimson compass
#

Create a new txt file in that folder using nano for instance

#

And put these in it

olive jungle
#

it hasn't finished installing seaborn

crimson compass
#

Ok just wait for it till it finishes

#

These are the required packages from those chapters

#

Found it on github

olive jungle
#

it looks done

#

i created requirements.txt

crimson compass
olive jungle
#

can you share url?

#

ty

#

running requirements.txt now

crimson compass
#

pip install -r the_file_you_created.txt

olive jungle
crimson compass
#

( go grab a cup of coffe coz it will be long )

olive jungle
#

@crimson compass it stopped

#

already

crimson compass
#

That should be dnspython

#

Not python

#

Check the first line of the requirements file

olive jungle
#

ok here we go

crimson compass
#

Cool

#

I think that all should be okey to run

#

Now

olive jungle
#

it's in progress

crimson compass
#

Yeh that's why I told to grab a cup of coffe

#

Coz silckit-learn as a package is way too heavy :')

#

Now last thing which I'm not sure about is that the script is trying to plot graphs

#

Dunno if WSL will pipe that into your graphical interface or will it crash pithink

#

Its 3 am here

#

Will be around for 15 minutes, hope you get that requirements installed by that time

#

And good choice to learn python 👋 👍

olive jungle
#

i started getting a lot of errors

#

but it's still running

#

i copied the 100% of the errors but not the entire output

#

(also thank you very much for your assistance)

crimson compass
#

You're welcome

#

Run this please

#

df -h

#

What is the % next to /

olive jungle
#

after the requirements.txt install is complete or in a separte terminal?

crimson compass
#

In a separate one please

olive jungle
crimson compass
#

Ok to be honest that's weird

#

Let it finish and then run your script

olive jungle
#

ok

formal schooner
#

did you guys figure it out?

#

oh geez looks like no

#

im still confused as to why apt install python3-* didnt seem to actually be installing python 3 packages

olive jungle
#

@crimson compass /mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17 Py ch01
❯ ipython RollDieDynamic.py 6000 1
/mnt/d/Section 9/Paul Deitel/ch01/RollDieDynamic.py:43: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show() # display window

/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17 21s Py ch01

molten wedge
#

@crimson compass /mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17 Py ch01
❯ ipython RollDieDynamic.py 6000 1
/mnt/d/Section 9/Paul Deitel/ch01/RollDieDynamic.py:43: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show() # display window

/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17 21s Py ch01

@olive jungle this problem can be solved by writing your statements in a jupyter notebook

olive jungle
#

I'm only interacting with the person I pinged

formal schooner
#

and no, it cant @molten wedge , this is part of an unrelated issue

molten wedge
#

oh okay, was just trying to help

olive jungle
#

@crimson compass i'm back. posted screen of problem.

crimson compass
#

Now last thing which I'm not sure about is that the script is trying to plot graphs
@crimson compass @olive jungle as I told you yesterday this will through an X display error while plotting

#

Otherwise the packages are ok

dull nymph
#

centos 7: how do I change the 'll' alias. I can't find it in bashrc or anywhere

#

got it /etc/profile.d/colorls.sh

crimson compass
#

hey @dull nymph it's been a while but i believe it's
~/.tcshrc

blissful sage
#

when scp something you need to

#
  1. use the command from the source user
#
  1. if the source user is a remote server, you do not need to provide the root@ip_address
hollow venture
#

when scp something you need to
is that a question, or an answer to a question?

blissful sage
#

it was a question but i figured it out

molten wedge
#

username doesn't check out?

toxic solar
#

Can I test these emojis they look cool!

vernal crystal
#

This is not directly python related

On unix, where would you expect a script to appear when you install something?
home/user/bin or maybe in the install location, but export PATH="$PATH:$HOME/install/location/here" is appended to .profile ?
I am new to unix so I don't know what the standard is. I want to automatically add a script to PATH.

hollow venture
#

Depends on the installation method.

#

Manual installation, /usr/local/bin/ is a good choice.

#

If it is packaged, /usr/bin or just /bin is good

vernal crystal
#

and those will be on path already or should I add those

hollow venture
#

/usr/bin and /bin should definitely be. /usr/local/bin should also be.

#

It is by default on arch, at least. (I use Arch, btw).

#
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
#

Also on Ubuntu

toxic solar
tight shard
#

you can do stuff like this in the off topic channels

#

!ot

shy yokeBOT
tight shard
#

@toxic solar

toxic solar
#

Yes?

#

I just like the emojis...

tight shard
#

yea that's nice but this channel is dedicated for a specific topic

#

the off topic channels were made for random purposes like these

#

I won't stop you if you want to continue doing it here

#

but just an idea

tender plinth
#

Hello , I've been trying to count the number of times a bash script is invoked , but storing count in a file and reading from it , can sometimes cause race conditions , so I dont prefer that method , another thing I came across is the flock which kind of holds a lock on file when an IO is happening on it , but Im not able to implement it properly , can someone give me an insight on this?

#
#!/bin/bash

file="/tmp/count.cnt"
flock -xn 200
trap 'rm /tmp/count.cnt' 0
RETVAL=$?
echo "acquiring lock"

if [ $RETVAL -eq 1 ]; then 
    count=$(cat ${file})
    if [$count -eq 0]; then
        echo "Building now"
        docker build -t container . 1>/dev/null
        docker run -dit --privileged container 1>/dev/null
        nc localhost 1234
    else
        nc localhost 1234
    fi
else
    echo "Sleeping"
    echo 0 > /tmp/count.cnt
fi

200>/tmp/count.cnt```
main olive
#

@tender plinth to lock the file in the current script's context, i've simply used

exec 4<>/my/file/here
flock -n 4
tender plinth
#

ah thanks @main olive

#

u dont check if the lock has been acquired successfully or not?

humble onyx
#

Hi. I am trying to understand what login means in linux.$ w USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT ennozdd :0 :0 10:47 ?xdm? 8:27 0.00s /usr/lib/gdm3/g
ctrl+alt+f3 to see how another console will show up$ w ennozdd :0 ennozdd tty4 - 20:08 13.00s 0.08s 0.05s -bashI also ran multiple instances of gnome terminal to see if each one counts as login but no it didn't make any difference in the output.
on tmux however there are multiple logins```ennozdd pts/2 tmux(11089).%0 20:11 3.00s 0.04s 0.01s tmux
ennozdd pts/3 tmux(11089).%1 20:11 2.00s 0.04s 0.04s -bash
ennozdd pts/4 tmux(11089).%2 20:11 2.00s 0.04s 0.04s -bash
ennozdd pts/5 tmux(11089).%3 20:11 2.00s 0.04s 0.04s -bash
ennozdd pts/6 tmux(11089).%4 20:11 2.00s 0.04s 0.00s w

formal schooner
#

@humble onyx gnome terminal doesn't use a login shell because you are already logged in when you are opening the terminal

#

you can start a login shell manually of course

humble onyx
#

1 - why did tmux make such a difference or why were my terminals not listed?
2 - Does :0 mean there is a GUI login?
3 - $ps aux gdm 1448 0.0 0.0 299432 7156 tty1 ennozdd 10577 0.0 0.5 698416 43256 tty2 Sl+ 20:04 0:00 /usr/share/discord/Discord there is also tty1 and tty2 I see

formal schooner
#

tmux specifically uses a login shell because tmux windows typically persist after the original login session ended

#

the idea is that you log in once per tty. tmux is a bit different because your tmux session is meant to be independent of whatever your current session is

tender plinth
#

Hello , Im planning to use nsjail over docker for one of my services which I intended to host over a server, but Im not really sure how we can use nsjail over docker, can someone give me an insight into this?

humble onyx
#

thank you @formal schooner

prime atlas
#

arch is a skid version of gentoo, change my mind

molten wedge
#

Is killing you allowed? @prime atlas

#

jk though

#

never used gentoo but I am an arch fan

molten wedge
#

I know it's difficult

#

Thats why ive never tried it

prime atlas
#

lol yeah that was my point haha

formal schooner
#

you arent building everything from source with arch

#

gentoo is wayyy more DIY

#

not even comparable

molten wedge
#

do people even use it?

#

I've seen people say i use arch btw (i use Arch btw) but never for gentoo

formal schooner
#

gentoo is still used but it has always been a niche community

#

see also: slackware

prime atlas
#

really nice for headless

hollow venture
#

gentoo is horrible for the environment tbh

#

just like mining bitcoin lol

tawdry sonnet
#

In my .bashrc file, how would I access this environment variable?

PAL:DriveLetter=V 

The usual $VARIABLE_NAME isn't working. It thinks that everything after the : is a command.

opaque ginkgo
#

${varname} @tawdry sonnet

tawdry sonnet
#

That's a step in the right direction, now it just prints a blank line like the variable doesn't exist.

formal schooner
#

i didnt know you could even have an environment variable with a colon in it

#

: is special syntax for parameter expansion in bash

#

so that wont work either

#

it might not actually be possible in bash

#

@tawdry sonnet maybe use python: python -c 'import os; print(os.getenv("PAL:DriveLetter"), end="")'

summer trail
#

the end="" doesn't really help; if you're using that from a shell script command substitution will strip off a trailing newline so that the end result is the same with or without end=""

#

I think you're right that there's no way to do it with bash, though. That's interesting.

formal schooner
#

Good point

tawdry sonnet
#

I'm using GitBash for Windows via the PortableApps launcher. The launcher passes these variables when launching GitBash, so I wanted to use a few for some custom functions and aliases.

I ended up writing a wrapper in python that will create the variables I need before launching GitBash. Works 👍

molten wedge
#

guys why does sudo cd directory/ give me a command not found error? I'm pretty sure I have cd lol

warped nimbus
#

Because it may not be on the PATH for the root user

#

Hmm wait

#

Is cd even a binary

#

Or is it like a shell built in?

#

Yeah I think it's a built in

molten wedge
#

it's a built ig

#

which cd gives an error if i remember correctly

opaque ginkgo
#

yeah bc otherwise it couldn't modify your current shell

#

since it's a subprocess

high nimbus
#

Is NS2 run on kali linux?

main olive
#

ns2?

serene eagle
#

do I need a Kali VM if I wanna do networking?

#

Like can I just use WSL

opaque ginkgo
#

context

#

Please

dull nymph
#

I just want the first PIID

#

using grep

molten wedge
#

@loud sky continue discussing here

loud sky
#

oh ok

#

How to upgrade?

molten wedge
loud sky
#

seems like python 3 is installed

#

when I typed python3 I get:

#

Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

molten wedge
#

then try pip3 install -r requirements.txt

loud sky
#

it is loading

molten wedge
#

cool but you'll also have to change the default python from python2 to python3

loud sky
#

The bash line - is blinking

#

ok

#

pls wait a some time

#

Its still loading

#

ERROR: Could not find a version that satisfies the requirement magic (from -r requirements.txt (line 4)) (from versions: none)
ERROR: No matching distribution found for magic (from -r requirements.txt (line 4))

#

The same error

molten wedge
#

ehhh

loud sky
#

argparse was installed

molten wedge
#

what linux mint version are you on?

loud sky
#

20 cinnamon

molten wedge
#

argparse was installed
@loud sky argparse is a pre-installed python3 module

loud sky
#

oh

molten wedge
#

I don't really know how to help you further

#

if you want, then you can open a help channel

loud sky
#

lets post this on general

#

how to open one?

molten wedge
#

you might not get a solution the first time, so don't worry about that, and open a new one as soon as you can (30 min)

loud sky
#

you might not get a solution the first time, so don't worry about that, and open a new one as soon as you can (30 min)
@molten wedge How to set default python as python 3?

molten wedge
#

I was looking that up

#

looks like linux mint > 19 should have it set as default

#

but yours doesn't

loud sky
#

Should I remove old python

#

By the way thanks for the help

molten wedge
#

that sounds like a bad idea, it's there for a reason

Should I remove old python
@loud sky

loud sky
#

oh

wise tartan
#

Hey! anyone knowledgable when it comes to setting up python on mac? i cant seem to get my terminal right

opaque ginkgo
#

just ask your question

#

@wise tartan

prisma wedge
#

How to make app like vitetris using python i.e. some gui on terminal

opaque ginkgo
#

curses

#

@prisma wedge

#

pretty sure I already told you this

lavish hemlock
#

I’m officially fucked

fresh saddle
#

What’s up?

formal schooner
#

arent we all

lavish hemlock
#

I have kinda bricked my phone

#

I created a file and put in the wrong directory

hollow venture
#

What phone?

lavish hemlock
#

iPhone

hollow venture
#

Maybe you can factory reset it.

lavish hemlock
#

jesus christ no

hollow venture
#

More importantly, what the fuck kind of file was it, and what kind of garbage phone breaks if you put a file on it? lol

lavish hemlock
#

i just gotta figure out how to delete the directory i made

#

it’s a .deb

#

and a bunch of .plist files

#

They get copied to the rootfs even after restoring it..

atomic ember
#

how can i run a python script in background? also i have a virtual env for it

blazing wolf
#

First u need to make sure the file dosent exit

lavish hemlock
#

The thing is, i need root access in a terminal to delete the directory

blazing wolf
#

Then u can use a systemctl service to run it in the background

#

@atomic ember

lavish hemlock
#

Its sandboxed :/

atomic ember
#

a little more details please, i am not that advanced, also i am using ubuntu

blazing wolf
#

yep, mb didn't read above

#

okay so

#

first thing, ur python file should run forever

atomic ember
#

yes

blazing wolf
#

like an infinite while loop or something like a server

#

2nd

atomic ember
#

it's already that kind of app, it's a discord bot

blazing wolf
#

we need to setup a service on linux to run that file

#

oh cool

#

i have a discord bot on a virtual machine provided by digital ocean

#

i use systemctl service to run it

atomic ember
#

i am trying to do that too

#

i am also using digitalocean

blazing wolf
#

basically u can write instructions for the system to perform some task

#

cool

atomic ember
#

ok

blazing wolf
#

i can share my service file

#

but first

#

i want to you to know it is and how to set it up

#

look at this article

#

read from turning it into a service

#

basically, u need to make a service file that the operating system can understand and perform the task listed in the file

lavish hemlock
#

Who pinged me?

blazing wolf
#
[Unit]
Description=YNB discord bot
After=network.target

[Service]
Type=simple
Environment="PYTHONPATH=/home/rohan/.local/lib/python3.8/site-packages"
user=rohan
WorkingDirectory=/home/rohan/YNB-DiscordBot
ExecStart=/bin/sh -c 'python3.8 -m ynb-bot'

[Install]
WantedBy=multi-user.target

this is my system service file i use to run my discord bot

lavish hemlock
#

@hollow venture did you ping me?

atomic ember
#

ok, thanks a lot

blazing wolf
#

i pinged by accident before when i mentioned sudo. is that wht ur refering to?

lavish hemlock
#

The terminal i am using doesn’t recognise sudo therefore i can’t get root access

blazing wolf
#

are you using pipenv or env @atomic ember ?

atomic ember
#

env

blazing wolf
#

okay, for the Environment variable, u want to set it to the env

#

in my case, i had installed the required packages gloablly so i refrenced the global python installation

atomic ember
#

and how i can set the env?

blazing wolf
#

i sent the script above

#

it has a variable Environment

lavish hemlock
blazing wolf
#

what kind of OS is that

lavish hemlock
#

iOS

atomic ember
#

it has a variable Environment
@blazing wolf i got it, thanks

blazing wolf
#

do su @lavish hemlock

#

it should prolly promt for root password

lavish hemlock
#

su isn’t recognised

blazing wolf
#

what happens when u just type su

lavish hemlock
#

It doesn’t recognise it

blazing wolf
#

maybe reach to customer support ? (might be confusing)

#

or reddit?

lavish hemlock
#

This is a sandboxed app though

lavish hemlock
#

Fixed my phone :))))

blazing wolf
#

cool, how did u do it @lavish hemlock ?

lavish hemlock
#

I sideloaded an IPA to my phone, used a different exploit to reinstall openssh and reset the root password, and deleted the directory

#

@blazing wolf

blazing wolf
#

nice

lavish hemlock
vestal leaf
#

hello mates I'm a newbie here

crimson compass
#

@vestal leaf hello howdy we all newbies in something :)

vestal leaf
#

ahaha thanx Zrouga, I'm appreciated to part of a community like this.

bold slate
hollow canyon
#

how to open arch cli in ubuntu cli?

main olive
#

what

#

what are you trying to do

molten wedge
#

arch cli is just bash terminal. what you can do in arch cli is the same as what you can do on ubuntu cli

hollow canyon
#

i want open arch architecture cli on ubuntu

ember isle
#

Not quite sure what you mean

#

The CLI/Terminal that you have on Arch is about the same as you'd have in Ubuntu, the main difference between them would be the package manager/packages if anything

tawny matrix
#

@hollow canyon you've got a bunch of options here.
First of all terminal emulator (or terminal for short) is the program you open that houses the shell (defaults to Bourne Again SHell or BASH for short).

There are a lot of options for terminal emulators (Termite, Terminator etc) and also for shell (bash, zsh etc). You need to specify which of the two you want to change, -probably the shell- but the default one should be BASH in both ubuntu and arch.

Only way to get a different shell during an arch installation is to use an arch based OS like ArchCraft which uses zsh as the default shell.

Please provide more information so we can help you further

molten wedge
#

Arch uses zsh during installation too, but it disappears as soon as installation is complete

#

weirdest shit I've seen

robust cave
#

it's weird because you don't understand it, the live ISO uses zsh + grml-zsh-config (https://grml.org/zsh/) as the features result in ease of use during installation (completion etc..)

the reason it disappears as soon as installation is complete is because the packages on the live media is separate from the packages you end up on your system

when installing arch, a step is to install the base package (https://wiki.archlinux.org/index.php/Installation_guide#Installation), which among other essential stuff installs bash, which is mandatory and an obvious choice for a default shell

it's up to you to install another shell and use that

molten wedge
#

yeah ik that.

#

but during configuring the archiso, what parts of the packages.x64_blahblah dissappear and which one remains?

robust cave
#

configuring the archiso
I assume you mean during installation,

after a standard installation using the guide (assuming no other packages are installed other than the explicit requirements), the only packages that are installed are linux, linux-firmware and the base package, the contents of which you can see here-> https://www.archlinux.org/packages/core/any/base/

molten wedge
#

I assume you mean during installation,
No no you assume wrong

#

i mean the archiso which is used to build the actual iso

#

@robust cave

robust cave
#

I'm not sure what you mean by actual ISO

molten wedge
#

so if i add Firefox in this list and install this newly built ISO on my computer, will I get Firefox in my new computer or not? @robust cave

robust cave
#

the Arch ISO is not what ends up on your computer, it's just the tool to help you get everything you need for a functioning arch installation

molten wedge
#

Is there a way that I build an iso so that Firefox is already there on my pc when I finish installation? @robust cave

robust cave
#

I'm not sure what you're talking about? you just have to install firefox (like pacman -S firefox in arch) during the installation process, and it'll be there when you finish installation

molten wedge
#

But suppose I have a large list of packages that I already need installed and I don't want to remember all those names.

#

for eg if you install Ubuntu on your system, you will find that dolphin file explorer is pre-installed

robust cave
#

hm, you could always keep the list of packages somewhere, then after a minimal installation install them all at once

#

if you do that frequently though, maybe look into something like NixOS

#

I'm not familiar with it though

molten wedge
#

yeah that could be done

hm, you could always keep the list of packages somewhere, then after a minimal installation install them all at once
@robust cave

dull nymph
#

2012.sqlite3
2012.sql
2012.xml

how do I rename these files to be
2013.sqlite3
2013.sql
etc

molten wedge
#

i think python script would be easier than using rename

dull nymph
#

yeah... fucking bash

molten wedge
#

um... that's a weird flex

dull nymph
#

Idk I used to like bash but since I learned python it feels so...

main olive
#

@dull nymph bit late on this one, but

#
NUM=2012
for filename in ${NUM}.*; do
  mv "${filename}" "$((NUM + 1)).${filename#*.}"
done
#

think a python script would be overkill here

#

yeah... fucking bash
@dull nymph if you can overlook the slightly unfamiliar syntax (but still nothing compared to other, more esoteric languages) then bash is very powerful

tender plinth
#

Hello , I've been trying to debug binaries enabled with Intel's Control-Flow Enforcement protection , is there a way to enable CET while compiling a binary with gcc?

dull nymph
#

Thanks @main olive that's a nice one

hollow venture
#

Probably a good idea to use mv -i so it doesn't overwrite existing files @dull nymph

fresh saddle
#

Where is that -v at though

hollow venture
#

Optional 😄 I tend to use it, but it won't cause data loss if not present.

solar glade
#

basically, I have a remote server running a discord bot, which I can connect to. the way I'm currently updating my code is using some file transfer tools every time I want to update my python code, then ssh-ing in to run the code again. Is there a way to push code from my computer to the server with git, and also force python to restart using the new code, so it doesnt take 5 minutes to update my code?

#

i know git supposedly can be used to push code there, but I also need the code to restart

#

the code is running in a screen so it stays even after I close my ssh client

hollow venture
#

You use GitHub @solar glade?

main olive
#

basically, I have a remote server running a discord bot, which I can connect to. the way I'm currently updating my code is using some file transfer tools every time I want to update my python code, then ssh-ing in to run the code again. Is there a way to push code from my computer to the server with git, and also force python to restart using the new code, so it doesnt take 5 minutes to update my code?
@solar glade a "deploy webhook" might be worth looking into

hollow venture
#

I think you can set up Github actions with a Github runner on your server.

#

I do that with GitLab, at least.

gloomy willow
#

How exactly do i suppress the output of this command ?

#
[ $(grep -oE 'gcc version ([0-9]+)' /proc/version | awk '{print $3}') -gt 5 ] && \
    echo "WSL2" || echo "WSL1"
opaque ginkgo
#

how are you running this?

gloomy willow
#

i tried adding > /dev/null but it was not proper

opaque ginkgo
#

try with bash

gloomy willow
#

same

opaque ginkgo
#

do you have some debugging option enabled

gloomy willow
#

nope

opaque ginkgo
#

try a different shell script

gloomy willow
#

i tried adding /dev/null after [ $(grep -oE 'gcc version ([0-9]+)' /proc/version | awk '{print $3}') -gt 5 ] but that did nothing

#

i also did zsh WSL.sh > /dev/null 2&>1 but hides everything lol

opaque ginkgo
#

make a new shell script

#

put echo hello world in it or smth

#

then run that

gloomy willow
#

why ?

opaque ginkgo
#

testing something

gloomy willow
#

that prints Hello World

#

clean

opaque ginkgo
#

none of the weird stuff at the beginning?

#

that's weird

gloomy willow
#

i think that's obvious to happen when executing some command i guess ?

thorny sage
#

anyone here using macOS?

#

was wondering if you were interested in collab

icy flicker
#

does anyone have enough knowledge about mariadb or mysql in arch here?

quasi pike
#

Pacman -S mysql

humble onyx
#
[ + ]  ufw
$ ps aux | grep ufw
#no output```Isn't a service supposed to be running in the background?
random mural
#

alright so uhhhh

#

i need a lot of help

#

so i've got this vps running ubuntu 20.04

#

and also bind9.16

#

it's running a website, so it provides DNS for that ig

#

but now i'm trying to also run a python script on it

#

and it keeps returning failure in name resolution

#

even though things like ```bash
$dig discord.com @127.0.0.1

#

it just doesn't work when i try to do it with Python

#

anyone have any idea how to fix this?

quasi pike
#

Trying to call a strange port?

fresh kite
#

.

random mural
#

not really, DNS should be on port 53 and I think I allowed that through firewall

wind adder
#

hey

#

HELP PLEASE!

#

I need to get rid off special characters between chr(128) and chr(153)

#

How do you do that in unix

#

and also I am getting an Illegal byte sequence error when I am trying use the cut command on file

formal schooner
#

@wind adder are you asking about doing it on the command line, or in python?

wind adder
#

Either way

#

command line would be nice

#

the problem is the encoding right now

#

it's trying to read en_UTF-8

#

and I think this file has characters not supported by that

#

I am trying to look into perl, but if you are aware of some perl, could you tell me how to do a simple regexp_replace with perl

#

cat file | perl s/regex/replacement/g

#

How about that, I have a very specific requirement to block out only certain latin coded characters

formal schooner
#

as bad as python 2 was with text encodings

#

python 3 is pretty good

#

do you know the actual encoding of the file?

wind adder
#

I think I do let me check

#

ISO-8859-1

#

oh actually do u know if tr works with hexcodes

#

ah dang okay i have to use another encoding

#

tr -dc '[:print:]' < infile > outfile

#

same problem, illegal byte seq

formal schooner
#

python can read that encoding

#
with open("myfile.txt", encoding="iso-8859-1") as fp:
    text = fp.read()
#

@wind adder

#

correctly reading the correct encoding is much better than arbitrarily deleting bytes...

wind adder
#

hmm u know what i think this is probably a better idea

#

than me trying to pick up sed and awk

#

at this point in time

#

still though i dont know if i shud really go the python route

#

cause the end goal here is to make some kind of a wrapper on an already existing bash command

formal schooner
#

your program only accepts utf-8 encoding?

wind adder
#

no no i dont think the encoding is a problem for the other bash scripts

#

i am trying to build a wrapper on another bash script thats making use of this file , i want to clean up some trouble some characters

formal schooner
#

why are they "troublesome"? you just need to read the file in the correct encoding

wind adder
#

we are using that characters properly for oracle db, but for some reason sales force craps out

formal schooner
#

maybe salesforce requires utf-8 input?

wind adder
#

the characters cant be processed well on some platforms

#

ya they might have a restriction

formal schooner
#

i recommend writing a small python script to convert the file from iso-8859-1 to utf-8

#

utf-8 is a better and more commonly used encoding nowadays

#
with open('file.txt', encoding='iso-8859-1') as fp_in:
    with open('file-utf8.txt') as fp_out:
        fp_out.write(fp_in.read())

that's it

wind adder
#

okay I will try it, I have to check to see if something in the oracle db is not dependant on those file characters too

#

thanks.

formal schooner
#

good luck. tools that use bad old encodings are a real nuisance

wind adder
#

Yeah agreed

opaque ginkgo
#

I have a really weird issue with nano + tmux

#

so basically, when I press the down arrow when my cursor is at the start of line 1(before the a), the cursor moves to before the 2nd line's line number and typing anything messes up that line's display

#

but this apparently only happens with all of the following: nano with line number enabled, tmux, and windows terminal

#

nano w/o tmux on wt works normally

#

nano w/ tmux but using cmd as the terminal works too

#

can anyone help?

dry bronze
#

I am having problems with pip3 on elementary os running ubuntu 18.04 on it

#

whenever I try to install using pip3 it gives this long error

molten wedge
#

your pip installation is probably wack

dry bronze
#

okay thanks

#

the issue got fixed

bitter charm
#

your pip installation is probably wack
@molten wedge my life indeed

bitter creek
#

Hey guys, I'm trying to use pip on my WSL but I run into this path error. I have added the path to my .bashrc (top row is the cat of .bashrc) but it does not seem to work

#

Anyone have an idea?

#

so I added export PATH="/home.." to the .bashrc already

molten wedge
#

@bitter creek i think you removed the pip from your PATH since pip should be installed in /usr/bin

bitter creek
#

let me check!

molten wedge
#

tbh, there's nothing to check. Unless you really need to, you should probably remove the export line from bashrc

bitter creek
#

Found a workaround, thanks for the input

main olive
#

Hi,
working on a Makefile and cant seem to even make simple stuff work

#
        @echo $$NUM
        @$(a=$$((NUM + 40000)))
        @echo $a ```
#

i just want to add 40000 to NUM and work on with that value

#

feels like I tried hundreds of combinations, but nothing seems to work

#

NUM comes from the CLI. so I run make start_cores NUM=3 and the first echo returns the correct number

neat wolf
#

So uh,i made an electron app and made an msi installer for it in windows ofc.
i packaged the app for linux too but idk how installers work in linux

fresh saddle
#

You usually don’t use installers for linux

#

What does the package looks like?

neat wolf
#

lemem show a ss

#

since im on windows

#

it show the packaged app as a unknown file

#

an*

#

its a folder

#

for the msi,i created a zip and the msi will just self-extract it

fresh saddle
#

Can you open the file as text?

neat wolf
#

lemme try

#

ok its a node js

#

script

#

and bunch of symboles

#

symbols

fresh saddle
#

Does the file start with #!?

neat wolf
fresh saddle
#

Hmm

#

Which encoding are you using?

crimson compass
#

Thats a binary file not a bash file

fresh saddle
#

Good catch, there’s the ELF magic number

neat wolf
#

oh

#

hmm

#

im confused xd

fresh saddle
#

It is a (linux) executable

neat wolf
#

ooh

#

@fresh saddle so i can run that in linux

fresh saddle
#

You should be able to

neat wolf
#

thats great ig but i want to share that

#

in github

#

as a direct downloadl ink

#

link

#

@fresh saddle thanks btw

fresh saddle
#

You probably want to create a release then

#

any time!

crimson compass
#

You are welcome

hot dragon
#

hey need some help with ubuntu grub boot loader anyone here??

raw ember
#

@hot dragon yes

nimble panther
#

what's up?

stark tide
#

Hi, I'm new to this linux ecosystem and I wish to repurposed my old 32bit system as a server where I can host some websites, and other web scraping scripts. I know about ssh using which I can connect to my Machine but how exactly should I run those scripts and host website. Like do we just roll it in terminal? If yes then how can I access that terminal so I can say terminal a script and run again

analog jasper
#

Perhaps have a look into crontabs, they are like shell scripts but they will run at boot or at a regular inteval

#

@stark tide

stark tide
#

Suppose I have 3 scripts running. One a scraper, a website and a bot for discord. Now I wish to access my pc via ssh and terminnate the scraper for maintainance. Is this possible via ssh?

molten wedge
#

yeah you have to find the process id for the scraper and kill it @stark tide

main olive
#

@stark tide look into systemd units

#

you can use them to manage "daemons" aka background processes. Run them at boot, stop/start them, etc

#

stopping your scraper would be as easy as systemctl stop scraper

stark tide
#

Thanks everyone

fickle wadi
#

hey yall. I was seeing the news about zsh becoming the default shell for mac. When I use the terminal does that mean I have to type zsh every time I use it? On startup it always runs bash too. So do I just disable the bash running on startup or have it run zsh on startup? Thank you!

opaque ginkgo
#

isn't that old news

fickle wadi
#

yes

#

I didnt find out until like last week

#

cause I read the zsh thing at the top

opaque ginkgo
#

but im pretty sure that only applies to new computers

fickle wadi
#

never payed attention to that

#

well I mean I am running a relatively new system

#

mac mini

opaque ginkgo
#

chsh if you already have bash as default I think

fickle wadi
#

so just change the shell?

fickle wadi
#

Alright I did end up changing the shell

#

However

#

Everything broke python wise

#

All packages are unrecognized and anaconda has given up

#

Probably has to die with path errors gonna fix it soon

#

Has anyone else had these problems?

desert oasis
#

Hello, can somebody help me out with starting a debugging session with pudb? I don't have much experience with Python, so I'm struggling to understand WTF is wrong. My goal is to debug calibre, at this point:

https://github.com/kovidgoyal/calibre/blob/master/src/calibre/ebooks/mobi/debug/main.py#L45

with this debugger:

https://documen.tician.de/pudb/starting.html

I installed it, I insert the breakpoint as the documentation says, I launch the script with

calibre-debug main.py -- /path/to/ebook.mobi

It says ModuleNotFoundError: No module named 'pudb'. Why is it not found if I installed it with pip?

main olive
#

@desert oasis haven't looked too much into the project, but it may be possible that calibre-debug uses its own virtual environment (where pudb isn't installed)

desert oasis
#

I see. Where can I see a list of modules that is inside virtual env?

#

Anyways, I'll go and read virtualenv docs, maybe that will help

main olive
#

add the following to the top of a file whcih you presume would be run inside the environment when calibre-debug is evoked:

from pip._internal import main as pipmain

pipmain(['freeze'])
#

this should print all of the installed modules

#

similarly, you can use pipmain(['install', 'pudb']) to install within the venv

#

(((this is under the presumption that it does indeed use its own environment)))

#

how did you install calibre in the first place?

desert oasis
#

Something weird happens:

    from pip._internal import main as pipmain
ModuleNotFoundError: No module named 'pip'
main olive
#

i installed calibre using my distro's package manager and calibre-debug does not use its own environment (and has pip) https://arse.ee/YrPluEy1.png

desert oasis
main olive
#

sec, trying that

#

yep, it bundles its own python version

desert oasis
#

It works alright, but the question is how to integrate it with external debugger.

main olive
#

not even a venv, a full separate python instance

#

honestly, my suggestion? use pacman's version of calibre

desert oasis
#

So I would have to rebuild it from source with pudb included in order for it to see it?

main olive
#

just be sure to do sudo /usr/bin/calibre-uninstall first

#

pacman's calibre uses the system's python install

#

so pudb etc works

desert oasis
#

But does pudb work if I install it with pacman? The reason I used their binary installer in the first place was because I could not even use print debugging if I install with pacman.

#

Although I inserted my print statements in the checked out soure directory and hoped it would respect CALIBRE_DEVELOP_FROM variable. Maybe I should have done it in wherever pacman installed calibre.

main olive
#

although i'm not sure if it respects that env var

desert oasis
#

I'll try that

main olive
#

hi guys, anyone here is using Mac OS?
I have Catalina build and there is folder called Others in my Finder - how can I access it? right now that function is greyed out

opaque ginkgo
#

@fickle wadi uhhh

#

can you post errors?

#

idk how changing your shell would break python

#

oh

#

fix your zshrc

#

copy the stuff in bashrc to zshrc and bash_profile to zprofile

#

if you have syntax errors, google what the right syntax is for zsh

wind adder
#

Hi Im working on unix terminal with python

#

im new to unix, how do you make a wrapper, I want to do some re.sub on the files that are passed as arguments to a bash cmd, and then recall the same bash cmd with the new file and same options

#

anyone have any experience with this

molten wedge
#
# wrapper.sh
output=$(python my_wrapper filename)
echo "$output"
# my_wrapper.py
import sys
print(sys.argv)

@wind adder Basically you have to catch the print statements in your python script and then use them in your bash commands.

wind adder
#

Hi IgnisDa thank you for reply, I am using sys.argv but I am having trouble thinking of how to structure this thing in general

molten wedge
#

In practice you should probably be using argparse

wind adder
#

right now I have something like this

Test.py:
import sys, re

with open(sys.argv[1],'r',encoding=...) as f:
print(re.sub(r'...','',f.read)
Now I want this to be actually called when lets say they type

Terminal: bash_cmd -iwdg s_list.txt

I will rewrite this bash_cmd
#!/bin/bash
python test.py $1 > $1
bash_cmd "this is the part im confused, how do I make sure all the args are passed in here, and I am not too sure if they will call this command on just one file too"

molten wedge
#

!code

wind adder
#

!code-block

shy yokeBOT
#

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:

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

Note:
These are backticks, not quotes. Backticks can usually be found on the tilde key.
• You can also use py as the language instead of python
• The language must be on the first line next to the backticks with no space between them

This will result in the following:

print('Hello world!')
molten wedge
#
#!/bin/bash
output=$(python test.py)
bash_cmd "$output" arg2 --named-arg arg3 --verbose

@wind adder I have no idea what bash_cmd is, so I will leave that to you

wind adder
#

It's not a real command I am using it as a placeholder for any bash cmd

#

But okay the thing is, what if they passed in multiple arguments into this bash_cmd to begin with

#

I want to make sure those arguments and options are still preserved

molten wedge
#

@wind adder edited previous answer

wind adder
#

oooo Okay perfect I will try this thanks

molten wedge
#

Yeah, also make sure to quote your variables like I did so that backslashes are not mangled

wind adder
#

ah yes

sick granite
#

I need help installing python packages!

#

I'm using a Linux based system that is on a chromebook and I installed everything to run Java files which I think is JDK and Java Envrionement. Now I want to try from python. I need to import a a package using "import turtle" but I'm not sure how to actually do that?

#

I think I'm suppose to download the linux version on anaconda but I'm not sure if that's the right way or even how to install/run it in my chromebook based linux.

#

Thanks!

vestal turret
#

turtle is part of the standard library.

#

Which distro are you using @sick granite not all of them include it by default

sick granite
#

I'm not sure what "distro"

#

but this might help since I followed it

vestal turret
#

ah, a chromebook

sick granite
#

Also, is the this appropriate discussion to put this question in?

#

I figures unix and linux was similar? I'm not sure.

vestal turret
#

You need the python3-tk package

#

sudo apt install python3-tk

sick granite
#

I just type that and I'm finished?

#

Don't have to go the anaconda route?

vestal turret
#

If you've installed that you should be able to import it.

sick granite
#

and that will give me other general files to import right?

vestal turret
#

That'll allow you to use pythons tk basked packages, turtle is one of those.

#

If you've got it you can put

import turtle``` at the top of your files
sick granite
#

can I just install all python packages if I exclude "-tk"?

vestal turret
#

no

sick granite
#

then how would I be able to install like all the general files for my python class?

#

Like the way Java uses JDK.

vestal turret
#

You should already have pythons runtime.

#

Since it's an important part of ubuntu

sick granite
#

hmmmm......so I have the general importable files? just not the tk based ones?

vestal turret
#

You have the rest of the standard library already

sick granite
#

how do I check if I have them?

vestal turret
#

You could try importing a few, but I guarantee you have them.

sick granite
#

ok

#

I have another question.

#

I'm trying to build a computer and I want to make it linux based. Would you recommend a Ubuntu enviornment? Like GNOME or something?

vestal turret
#

Ubuntu is a fine choice.

sick granite
#

whats the diff between that and GNOME?

vestal turret
#

Ubuntu is a distribution (distro), GNOME is a Desktop environment.

#

They are fundamentally different things

sick granite
#

so Ubuntu is like my OS and Gnome is just how the desktop will look after processing Ubuntu?

main olive
#

yeah the top layer of what you see is gnome

#

the kernel and all services are those of ubuntu

gloomy willow
#

has anyone played with GRUB before ? I'm thinking of making a GRUB2 theme

#

can the menu items be resized to a rectangle or square shape?

thorny sage
#

guys i need to convert a .exe file to a .msi using python
anyone knows some possible solutions or packages that i can use for this?

chrome sierra
#

you can package an executable in the .msi file but converting the actual code is probably impossible

viscid jungle
#

Hey, I was wondering: are environment variables just a feature of the shell, or a feature of processes?

#

I.e. does a process not launched from a shell have environment variables?

#

Where are they stored?

opaque ginkgo
#

yeah it does

#

main on unix systems takes (argc,argv,envp)

viscid jungle
#

Ah right, so they are part of the process control block?

#

Ok, turns out they are stored in the process's memory.

main olive
#

How can I come up with a grep that gets me all objects that have the string MyServer1.1.* - the idea is to get the whole json from { "ip"............MyServer..... to end of json object }, https://dpaste.org/yFVR

viscid jungle
#

Hmm, you want to parse json with grep?

#

It might be difficult because json isn't a regular language.

main olive
#

but i think is possible because the different flags grep has tho

#

i just need to identify the init char, a middle reference and the end. Copy everything between

#

like some kind of regex for grep

opaque ginkgo
#

but use jq or something

viscid jungle
#

Do you have to use built-in unix tools?

opaque ginkgo
#

^

main olive
#

not really

#

i checked groun seems like can do the job

#

but why you say to use jq

#

well seems like gron cant find some of the objects in the file :/

#

@opaque ginkgo gron dont find some objects because of unicode

#

grep can't parse json

#

use jq

opaque ginkgo
#

or just use an actual json parsing lib

#

with python

main olive
#

can you guys gimme some help with jq

#

maybe jq can do it and i dont have to code anything like it, but if jq cant do the job that's what i need to do

viscid jungle
#

Actually, perhaps you could write a small python script to do this?

#

Python has json parsing in the standard library.

#

This is the python discord, just saying 😄

#

And python is available on most unix installations today.

main olive
#

ye but im parsing stuff thats coming from another software and i dont want to code something just to use more ram

#

however, my json file contains some unicode as you guys can see on the paste

#

and even with jq, i dont get the data im interesting in due

#

parse error: Expected value before ',' at line 1, column 125

#

and i dont have control of the json data

#

how it is generated

viscid jungle
#

Ah right, so it's not necessarily valid json.

main olive
#

but it seems to generate a valid xml, what similar tools i got for xml?

viscid jungle
#

Maybe xpath?

main olive
#

im trying it out, can u help out with the syntax please? first time using it

#

it should get the object starting from <host..> but only those with the string MyServerV1.1. in the middle

#

xpath -q -e '//host' goxml.xml

#

gives me the element i want but i still need to filter the results by MyServerV

main olive
#

any feedback guys?

tender plinth
#

Hello , I've been trying to print names of caller functions inside a segfault handler , and with builtin_return_Address function , I dont seem to get meaninful results. I've also tried using a foreign library called libbacktrace but it segfaults even before calling it's internal print statements (which are async-unsafe) , moreover I also tried changing all printfs to write , that also to no use. Does anyone have a better way to printing caller function names from inside a signal handler?

stark tide
#
        if browser == "firefox":
            self._options = F_options()
            if binary_location is not None:
                self._options.binary_location = binary_location
            if headless:
                self._options.add_argument("--headless")
            if options is not None:
                for option in options:
                    self._options.add_argument(option)

            self.driver: FireFoxDriver = webdriver.Firefox(
                executable_path=executable_path,
                options=self._options, # Some how this line is causing error
            )```
#
  File "rex.py", line 37, in <module>
    options=ARGS,
  File "/home/avinash/CodingStuff/Projects/Rex/RexWrapper.py", line 57, in __init__
    options=self._options,
  File "/home/avinash/.local/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
    self.service.start()
  File "/home/avinash/.local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1436, in _execute_child
    executable = os.fsencode(executable)
  File "/usr/lib/python3.7/os.py", line 809, in fsencode
    filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType```
#

works fine on my windows, throws this error on my Linux Machine

lavish hemlock
#

is there a way to cd back by two directories

hollow venture
#

cd ../../

lavish hemlock
#

O

opaque ginkgo
#

@stark tide 2 things: you need to do export GECKODRIVER_PATH=...

#

the reason why PATH doesn't have it is because its already exported by something earlier

#

secondly, move that line to the very bottom of profile

#

not within any if statemnts

stark tide
#

@opaque ginkgo yeah, I just got done with it

#

Btw, how can I keep a process running even after I quit terminal? I'm accessing my linux box setup on local network on windows and want to use it to run stuff 24/7 for scrapers, websites and bots

#

I tried running a python bot and it stopped once I quit terminal on my windows

opaque ginkgo
#

vm?

#

@stark tide

hollow venture
#

Btw, how can I keep a process running even after I quit terminal? I'm accessing my linux box setup on local network on windows and want to use it to run stuff 24/7 for scrapers, websites and bots
@stark tide you ssh into the linux box? You can use tmux for that.

#

tmux new -s mybot to start a new session called mybot

#

Run the command, then ctrl+b, D to detach from the session

#

tmux ls to list sessions, tmux a -t mybot to reattach

stark tide
#

Thanks @hollow venture

hollow venture
#

There are other options, of course. You can dockerize apps, and run those as daemons.

#

But tmux is the most hassle free.

past sluice
#

hi i need help

#

i got this error

#

File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: ' lsblk | grep disk | wc -l'

#

when i run this subproocess command

#

total = subprocess.check_output(' lsblk | grep disk | wc -l', stdout=subprocess.PIPE).stdout

spark veldt
#

add shell=True

#

you are running a bit of shell (bash) code, not just one process

opaque ginkgo
#

your code throws a different error when i tried it

spark veldt
#

(the other way would be to use three Popen objects, with stdout connected to stdin of the next command)

opaque ginkgo
#

either use explicit stdout= or check_output, not both

#

it should be subprocess.run in this case

placid wharf
#

I'm working on packaging Ren'Py as a flatpak which succeeds in building and can run some example games, however there are some issues at runtime that I'm trying to tackle. One big issue is that it requires tkinter which seems to be shipped inside the flatpak build, but it can't seem to find that package (looks like tkinter has been moved to /lib/python3.8/site-packages/future/moves/tkinter inside the build) so a lot of GUI functionality isn't accessible. Does anyone know how this can be fixed? Here's what the build manifest looks like: https://gist.github.com/joshua-stone/398854037400b05ce43884e8145ffd2f

Gist

GitHub Gist: instantly share code, notes, and snippets.

wary crane
#

What is redhat linux?

#

Can i install Kali instead of Ubuntu?

dreamy wing
#

Its not advised to install kali because its goto user is root. But it is possible. If its the tools you want, you can just install them separately. Most of them dont see much use anyway.

wary crane
#

okayy

dreamy wing
#

anyone know of any good wpa_supplicant libraries, preferably over dbus?

opaque ginkgo
#

kali doesn't default to root anymore

#

@dreamy wing

#

it's now kali:kali

#

but yeah don't use kali if you're a beginner

#

if you're asking that question, you shouldn't be installing kali

hard bear
#

Hi guys need help with my Amazon EMR...trying to access python file using EMR

#

The python file I'm trying to execute it "pi.py"

opaque ginkgo
#

your scp syntax is wrong

#

scp /path/to/local user@remote:/path/to/remote

#

@hard bear

hard bear
#

Thank you

wary crane
#

@opaque ginkgo but i want to learn having in future

#

Hacking*

solemn snow
#

does
unix == linux?

opaque ginkgo
#

no

#

@wary crane you don't need kali to learn hacking

#

i've been doing ctfs with a vanilla wsl debian install

#

@solemn snow unix nowadays refers to many different os's that are similar to the original unix, which was an os developed in the 70s

#

linux is a os that is classified as a unix

#

but its not the same

#

for instance bsd variants are unix but not linux

solemn snow
#

oh so can we ask windows related questions here?

opaque ginkgo
#

no

#

windows is not a unix

#

unless its a wsl question

solemn snow
#

ohh

#

ok

wary crane
#

Okkay @opaque ginkgo thanks for info

granite aspen
#

Last night I tried to dual boot Linux onto my computer, but apparently I had to shrink the main partition to create space for the new one. And it wanted me to defragment before shrinking the main partition. Which I guess makes sense so that you can have contiguous space for the new partition. But it never got above 0% defragmented even though I just reset this computer so why would there be so much to defragment?

analog jasper
#

What distro was it, maybe the defrag was bugged

#

@granite aspen

granite aspen
#

@analog jasper my computer is primarily windows and I was going to add a Mint partition

#

Namely windows 10

hollow venture
#

@analog jasper my computer is primarily windows and I was going to add a Mint partition
@granite aspen were you running the defrag in Windows? Maybe try gparted .... https://gparted.org/livecd.php

granite aspen
#

isn't that for partitioning if you're currently running linux?

analog jasper
#

Nah you can run gparted on a live stick

hollow venture
#

Yup. The link I shared was for the live CD/USB.

#

The advantage is that you can operate on an unmounted FS, so you know files are not in use.

#

(Note that I haven't had to deal with a Windows partition since Win 7, so not sure how well it works with win 10).

main olive
#

I did erase everything and install linux 😛

But yeah the gparted should work, what I used to do before was create a partition in windows using that disk partitioning GUI and then during the live install selected that partition as main one and default windows bootloader partition to install grub.

#

Now I know I was so dumb doing that.

opaque ginkgo
#

whats the difference between /etc/binfmt.d/, /proc/sys/fs/binfmt_misc and /usr/share/binfmts?

#

qemu and python install to usr, wsl and maloader to proc and nothing to etc

coral copper
#

shiny.

eternal swallow
#

@quartz zenith

#

talk in here

quartz zenith
#

My Gentoo Setup was like this

eternal swallow
#

how did that ruin ur pc?

quartz zenith
#

I Am Not Comfortable

#

With this interface

#

At First it was like win xp

Then i customised it

#

But Still It Looks Ugly

eternal swallow
#

i dont think gentoo linux would be about looks rather than the functionality

quartz zenith
#

Yeh

eternal swallow
#

pop os linux looks pretty good

#

or ubuntu

quartz zenith
#

It Doesn't have Software store top

eternal swallow
#

currently i have ubuntu on my second computer with oracle vm with kali linux and windows 10 vms

quartz zenith
#

This looks cool to me

#

Solus Os

eternal swallow
#

yeah i dont think thats meant for devs tho lol

quartz zenith
#

I am on user friendly interface

#

For me clean UI Matters More

coral copper
#

want clean UI use i3. 😛

quartz zenith
#

I use i3 with 8GB

uncut bloom
#

i have 4 python versions in linux mint
python-3.8.2 (global)
python-3.8.6 (altinstall)
python-3.9.0 (altinstall)
python-3.8.5 (anaconda)
i want to uninstall 3.8.6

#

please help

quartz zenith
#

Simple

#

Aww Linux Mint

#

idk Then

#

If it was windows i can help

opaque ginkgo
#

@uncut bloom installed from source or from the package manager?

uncut bloom
#

@uncut bloom installed from source or from the package manager?
@opaque ginkgo from source

opaque ginkgo
#

does it have a make uninstall target?

thorny sage
#

guys i am using wmic in order to uninstall a package from a computer

#

the issue i am facing is that

#

even though sublime text shows up on my programs and features menu, it does not show up in the output from wmic

opal rock
#

Solus Os
Solus is so cool. I love it !

turbid marsh
#

Why not Ubuntu?

molten wedge
#

bloated

main olive
#

haha its ok if you want to get into linux

molten wedge
#

Yeah it is ideal for that. It's extremely stable too.

formal schooner
#

For me it's less about bloat and more about "I don't trust Canonical"

#

That said I do use Mint Cinnamon at home on my "big" PC, I'm a big Mint fan

main olive
#

rolling release distro are the best to me

half crow
#

hi hi~

#

may I ask help for linux bash here?

#

holy crap

#

this is a python server xd

hollow venture
#

may I ask help for linux bash here?
@half crow you can. The unix channel isn't python-specific.

half crow
#

:0

#

then, here we go

#

Hi~~ As the server rules require, I will try to explain my issue the best I can. Please forgive me if my english is not very good and ask me anything. Thank you in advance.

TOPIC: Log commands from different ssh connections to the bash history files

  • Scenario:
    Lot of servers Linux Centos 6/7 with 2 users: noroot and root.
    It is required to keep a minimum track on the commands issued in SSH bash sessions, without adding more users to
    this servers.
    Clients are customizable.

  • Idea:
    Since there is no problem modifying SSH clients, the main idea resides on taking advantage of SSH's SendEnv feature
    to send a variable $GIT_NAME to the server, previously defined and exported when opening a local bash shell ~/.bashrc .

    Given this situation, what would be the best option to keep a track on every "user" identified with the variable
    $GIT_NAME?

-Main approach:
My main approach is to make use of the history command in ./bashrc with
PROMPT_COMMAND=history -a $GIT_NAME.history ; echo $(head -n1 ~/.$GIT_NAME.history) >> .bash_history .
Why like this? Well I can't make it work.

Ideally I would type `history` and the format would be something similar to this one: 
https://www.linuxtechi.com/enable-timestamp-history-command/
..,but adding the variable if received.
`.bash_history` writes the timestamp with a Unix Timestamp commented before the line, like:    ```

#160005455
sudo shred /etc/*
#160005600
ls /etc/ -lhta
#160005941
echo "OK"

hard bear
#

Need help with PySpark RDD

tardy gazelle
static vine
#

hi I moved to windows... saddly BUT atleast i still have my linux 🙂

#

i use all my python stuff over here because i have more space but setting stuff up from github is over there

hard bear
#

Hi, it's me again needing help with my code

molten wedge
#

vim goes brrrrr

hard bear
#

I'm trying to print the prime numbers and then count of the prime numbers

#

But this code of mine will print 100 times of every prime numbers...the count prints 100

molten wedge
#

if you have an upper range, you can use the Sieve of Eratosthenes method. It's much more reliable, faster and cleaner.

hard bear
#

Hmm...ok I'll check it out

#

Thanks @molten wedge

main olive
#
def prime(n):
  if n == 2:
    return True
  for i in range(2, n - 1):
    if n % i == 0:
      return False
  return True
#

This is the brute force way to check if a number is prime
Time Complexity; O(n)

#
def prime(n):
  if n == 1:
    return False
  if n == 2:
    return True
  i = 2
  while i * i <= n:
    if n % i == 0:
      return False
    i += 1
  return True
#

This is the best way to check a number is prime or not
Time Complexity: O(sqrt(n)

warped wing
#

what does exporting a variable do?

formal schooner
#

@warped wing in the shell?

#

It makes it part of the "environment" which is inherited by child processes

hard bear
#

@main olive Thanks a lot! I've managed to use your code and fix it a little to make it work

molten wedge
#
def prime(n):
  if n == 1:
    return False
  if n == 2:
    return True
  i = 2
  while i * i <= n:
    if n % i == 0:
      return False
    i += 1
  return True

@main olive i remember this answer was part of project Euler.