#unix

1 messages ยท Page 39 of 1

magic basin
rich oriole
#

a=`date +%A%_d" "%B", "%Y" @ "` && echo -n $a && echo $(date +"%r" | sed -e 's/\([0-9][0-9]:[0-9][0-9]\):[0-9][0-9]/\1/')

#

that's the code

#

the key component here is echo -n

magic basin
#

Is it different for me or does the @ and the 2 meet

#

@02:58 PM

#

there should be a gap

rich oriole
#

you can just add it a=`date +%A%_d" "%B", "%Y" @"` && echo -n $a" " && echo $(date +"%r" | sed -e 's/\([0-9][0-9]:[0-9][0-9]\):[0-9][0-9]/\1/')

main olive
#

@rich oriole use $() for shell expansion

magic basin
#

oh i see

#

i didn't know you could do things like = in linux

#

unless in a script

rich oriole
#

@rich oriole use $() for shell expansion
@main olive I know, I just used backticks at first so wanted to solve issue with discord, I don't like when somethings doesn't work as expected :d

#

i didn't know you could do things like = in linux
@magic basin you can do anything in-line

#

however sometimes things are slightly different but still possible

magic basin
#

yeah

left pilot
#

this course i am on says run this: docker run -it -p 8888:8888 -p 6006:6006 -v "%cd%":/host -w /tmp tensorflow/tensorflow jupyter notebook --allow-root /host
but the jupyter launch command fails

#

can someone help?

main olive
#

i suggest you try another guide @left pilot, this one seems to be windows-specific

#

"%cd%" is a cmd.exe thing

left pilot
#

yes, it was $PWD but i changed, as i use windows

main olive
#

should replace that with $(pwd)

#

oh

left pilot
#

sorry @main olive i am not the strongest programmer

main olive
#

what error does it fail with

left pilot
#

the course i am on with Eduonix, the code it incomplete and quite poor, and i am at a brick wall

#

bare with me

#

docker auto update

main olive
#

can you post the full error message?

left pilot
#

yes

main olive
#

k

left pilot
#

C:\Users\Jordan>docker run -it -p 8888:8888 -p 6006:6006 -v "%cd%":/host -w /tmp tensorflow/tensorflow jupyter notebook --allow-root /host
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: "jupyter": executable file not found in $PATH": unknown.

#

the container element works, but the jupyter launch fails

#

i have integrated jupyter into my paths

#

to be specific, i have added the jupyter launch directory to my PATH system variable

#

and i can launch jupyter by executing 'jupyter notebook' in the cmd terminal

main olive
#

the system's $PATH does not carry over to docker

#

you might have to point directly to where you think the jupyter binary is in the container with an absolute path

left pilot
#

i see, do you know how i would locate the jupyter binary?

main olive
left pilot
#

to be honest, i'm just doing what the course tells me to do, I could certainly try a different approach

#

setting it up now ๐Ÿ™‚

main olive
#

i recommend looking at this

#

it's good documentation

left pilot
#

yes, thanks

main olive
#

hi

#

I need help

#

I know how to ping an ip or resource

#

but how do you ping an ip through another ip

#

master (where I am) --> worker IP ---> another IP

#

I want to check whether the worker can reach the other ip

modern kestrel
#

ssh into it?

main olive
#

I can't ssh.. the network rules don't allow it

#

ssh to worker I mean

#

unless the "worker" is set up for forwarding packets, what you're describing is impossible

modern kestrel
#

then modify so you can

main olive
#

forwarding packets?

#

yes, so that the worker forwards the ping packet to the other IP and the response back to you

#

oh

#

hmmmm

#

how do I check workerIP-->another IP connectivity then

main olive
#

I figured out a workaround.. but I would like to know this..

digital haven
#

If I change a file that's regularly rsynced to a server, will rsync load the whole file or the diff?

main olive
#

just the different part @digital haven

#

different from last backup, that is

digital haven
#

@main olive oh ok, ace... I couldn't remember. So if I have a 500mb CSV and add a line it'll just upload the line, cool

main olive
#

yeah, it should only upload a chunk of the CSV and not the full file

magic basin
#

Why does my ssh script not work when i compile the .bat to an .exe

cinder wren
#

anyone know how i can get a screen region when using x11vnc / vncdotool or some other way of interacting with the vnc via python?

fringe pollen
#

What is the correct cron expression if I want a command to run every 90 days?

magic basin
#

nano > vim

magic basin
#

how can i sync all terminal sessions, so when i run something like echo hi all my logged in sessions will display it?

#

if i have two logged in root users for example

main olive
#

@magic basin screen can do that

magic basin
#

Oh ok

magic basin
#

Screen is good

#

Very useful command

main olive
#

hello

gloomy wolf
#

Hi

main olive
#

Hi Everyone - trying to get cron to run a python script for me.... i am new to Python so not sure if my job is correct. Cron isnt executing the actual .py script.... here is job:
*/20 * * * * /usr/bin/python3 /home/ubuntu/casey-trader/get_token.py >> ~/cron.log 2>&1

#

normally to execute i just run python3 get_token.py in that directory

#

anyone?

modern kestrel
#

@main olive does your script start with .

#!/usr/bin/python
main olive
#

@modern kestrel I figured it out now, thanks!

#

i had default python when i needed python3

modern kestrel
#

if so then

*/20 * * * * /usr/bin/python3 get_token.py >> ~/cron.log 2>&1

``` would work maybe?
#

oh okay great

#

yes of course

serene sigil
#

Terminal Error E: Package 'python-software-properties' has no installation candidate What Does That Mean?

modern kestrel
#
sudo apt-get install software-properties-common
#

run this @serene sigil

#

if it still doesn't fix it run

sudo apt --fix-broken install python-pycurl python-apt
serene sigil
#

thx

#

Separate Question: What do I do to fix this error? $ sh cmake.sh --prefix=(pwd)/cmake-test-install sh: 5: Syntax error: "(" unexpected

fickle granite
#

put a $ before the (

serene sigil
#

k let me try

#

Thanks

fickle granite
#

๐Ÿ’

magic basin
#

can ssh show the os of a logged in user

#

like for example: windows

main olive
#

i'm fairly certain SSH only sends the client's version and not the full OS information or so

abstract garden
#

is there a way to note all installed rpms and then install those on a different machine?

#

With packages that have dependencies, it looks like they need to be installed together or it'll throw an error (without internet)

magic basin
#

@main olive What is Raw, Rlogin, and Serial used for

#

I'm aware of SSH, Telnet and MOSH

main olive
#

where do you see those options?

#

rlogin is https://www.ssh.com/ssh/rlogin, serial is for... well, serial stuff, like UART and so. Raw is I assume reading/sending characters directly over a TCP socket or file

#

they're all different methods for connecting to a "terminal"

#

is this putty or something?

frank coral
#

Is there a command of the os module to know how much RAM has a computer? On linux

fickle granite
#

doubt it

#

you could run a command like "free" and parse the output; there are probably 3rd-party libraries that do the equivalent of that.

#

I'd guess "ansible" has something like that, but that's not a library; it's a complex application

#

that's probably what I'd use

main olive
#

ouch, using ansible just to get the amount of memory a system has

#

like using an RPG to hunt ducks :p

fickle granite
#

well I was just thinking out loud!

#

note I said "it's a complex application"

main olive
#

i know, i know, i'm just joking around

fickle granite
#

mutters

main olive
#

what does file /media/bitlocker/dislocker-file say?

magic basin
#

am i able to get rid of these annyoying lines in PuTTY when the server banner is displayed?

steel verge
#

Not really a help, but do yourself a favor and move to Bitvise SSH

#

putty is, ugh, meh

magic basin
#

I'll check it out, i use KiTTY too

steel verge
#

Windows 10 has also built-in OpenSSH, but I've found that the command shell is not really doing well with it

#

But Bitvise is modern and works well for me with all systems

magic basin
#

Bitvise is horrible

#

Barely any configuration options compared to putty

steel verge
#

That is factually wrong, but ok.

magic basin
wintry pagoda
#

Hey everyone..
please tell me how to listen incoming desktop notifications using libnotify or dbus-montior ..
Actually i want to create a systemd script for this process like, if a notification pop-up then service gets start and check IF it come from specific sender.. IF yes, then start another script in background otherwise do nothing

main olive
#

@cerulean pagoda and the following fails?

sudo losetup -f -P /media/bitlocker/dislocker-file
#

(if you get no output, see if it appears in sudo losetup -l)

gusty wedge
#

Does anybody have experience with kvm vm backup and restore when a hosting provider doesn't give you the option to do it through control panel?

main olive
#

ok, cool, what does ls -l /dev/loop0* say?

#

one of those is the partition you want to mount @cerulean pagoda

#

should be able to just go ahead and mount it like normal

#

hmmmm

#

that's... odd

graceful berry
#

@main olive can you give me a hand here then?

main olive
#

Yes, what do you need

graceful berry
#

Can you take a look at this script and see if its in your expertise?

main olive
#

post the script :p

graceful berry
main olive
#

this is not a script

#

it's a shell transcript

graceful berry
#

Well thats what I was saying

main olive
#

ie, a history of someone running commands and what their output was

#

the lines beginning with $ are the commands, and the output is what proceeds after that

#

only the very last thing at line 304 (from the shebang line to the end) seems to be a script of some sort

graceful berry
#

Ok well what use can I make of this? The person sent it to me to learn and maybe reuse in the future

main olive
#

maybe you can learn the commands listed here? Looks like he's also written some explanation into the output itself

#

I don't really know what this could be useful for, I'm not familiar with whatever the beautyworld thing is

graceful berry
#

its just a site

#

that I needed info from

#

he wrote some explanation but its all mumbo jumbo to me

main olive
#

I'm not sure scraping this data is allowed by the site's terms of service...

#

!rule 5

shy yokeBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious/inappropriate or be for graded coursework/exams.

graceful berry
#

well definitely not malicious

fresh saddle
#

But it does breach the terms of services

graceful berry
#

and what term is that

small kraken
#

anyone got experience running a python script as a systemd unit? I'm trying to run my discordbot through it, and it's sort of working but the logging isn't working the way I want it to.
The bot uses print(stuff) to output things like who executed what command etc, and it has ascii escapes to colorise the output.

But there are two issues when running it through systemd:

  1. output is only captured by journalctl when the server restarts
  2. my fancy color coding isn't visible
[Unit]
Description=MrFreeze (beta)
After=network.target

[Service]
User=mrfreeze
Group=mrfreeze
WorkingDirectory=/srv/mrfreeze
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=MrFreeze
ExecStart=pipenv run bot

[Install]
WantedBy=multi-user.target

I first did it without the standardoutput things but it doesn't seem to matter.

#

so when it's restarted everything that it should've outputed is outputted as if it was just printed, with the time stamp saying the current time, rather than continously printing it.

main olive
#

have you considered using the logging module instead of just prints?

#

it will make your life a fair bit easier

small kraken
#

what does it do?

main olive
#

provides a logging backbone

#

it can also integrate directly with systemd.journal

small kraken
#

how is it different from just printing?

main olive
#

you have different logging levels, can apply filters, don't need to necessarily log to stdout, etc

#

it's far, far more powerful than just printing

#

you can also decouple the log messages from the actual format

#

so if you ever want to change anything regarding how your logs are printed, nothing breaks

small kraken
#

hm, I will look into it. I think almost all logging already goes through a logging cog (sort of a module in discord.py) so it should be easy to change

dim talon
#

Hey, I'm writing a log-monitoring daemon, but I think my question is more code debugging-related, is this an appropriate place to ask questions (I'm new here)?

#

Never mind, I figured out how to use the help channels

uneven spade
#

I'm horrible at python, but I just built a module.... I am not tryiung to import the module, but it isn't being found by my python.

Any suggestions?

Running Ubuntu
Trying to build Ettus UHD Python API

#

I am trying* (Disregard the "Not")

solar peak
#

init.py inside the folder

#

else from .filename import method if it is in the same directory

main olive
#

How do I use relative paths?

#

Like if how do I find a file that's in the same folder as the code?

#

/home/chronos/u-b1c59786803a0df1da5dda85e37e6fd9fa03f528/MyFiles/Downloads/TeccaTest/cogs/ffmpeg-git-amd64-static.tar.xz was not found.

#

I'm going to use relative paths instead, so tell me how to use it.

#
    async def from_url(cls, url, *, loop=None, stream=False):
        loop = loop or asyncio.get_event_loop()
        data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))

        if 'entries' in data:
            # take first item from a playlist
            data = data['entries'][0]

        filename = data['url'] if stream else ytdl.prepare_filename(data)
        return cls(discord.FFmpegPCMAudio(filename, executable="/home/chronos/u-b1c59786803a0df1da5dda85e37e6fd9fa03f528/MyFiles/Downloads/TeccaTest/ffmpeg-git-amd64-static.tar.xz", **ffmpeg_options), data=data)```
misty vessel
#

I just do folder/

main olive
#

@misty vessel So folder is the current folder of the code or the home dir

misty vessel
#

so

main olive
#

the ffmpeg is inside the code folder

misty vessel
#

to you, the folder is folderpyscriptisin/folder/ but the script will see as folder/

main olive
#

So for the code: folder/ffmpeg-git-amd64-static.tar.xz

#

@misty vessel

misty vessel
#

probably

#

yeah

#

I just installed ffmpeg with apt install ffmpeg so I don't have to deal with that

#

it added to path, at least in ubuntu 19.10

main olive
#

so

#

when I deal with ffmpeg should it look like that?

#

Because I've seen them end with .exe etc.

#

@misty vessel

misty vessel
#

.exe is windows

main olive
#

ooo i get it

misty vessel
#

my discord.FFMmpegPCMAudio looks like discord.FFmpegPCMAudio(pathtoaudio)

#

or more broadly vc.play(discord.FFmpegPCMAudio(pathtoaudio))

main olive
#

so u have installed ffmpeg before? @misty vessel

misty vessel
#

yes

#

just by doing apt install ffmpeg

#

in the terminal

main olive
#

hmm

#

@misty vessel didn't u need to place anything in a folder or something?

misty vessel
#

nope

#

nothing

main olive
#

so u dont need the ffmpeg?

#

what a bit

#

what kind of music bot did u make?

main olive
#

@misty vessel

misty vessel
#

I made a TTS Bot

#

if you want invite dm me

#

apt install ffmpeg is installing ffmpeg lol

main olive
#

@misty vessel I could tell.

main olive
#

how can i make python execute linux commands

fickle granite
#

subprocess.run

main olive
#

thanks

fervent gale
#

whats wrong with subprocess.Popen()

warped nimbus
#

Nothing

#

It's just a relatively lower level interface

#

If you need access to more settings and features then use it

main olive
#

so

#

subprocess.run(command)?

fickle granite
#

sorta

#

as long as command is a list of strings like ['/bin/echo', 'hey', 'you']

#

it's documented, you know

main olive
#

ty

lavish hemlock
#

When you create a new user, it asks for the full name and phone number. Where is this information stored and how can i view it?

livid verge
#

@lavish hemlock

import pwd
print(pwd.getpwnam('nosklo').pw_gecos)
main olive
#

@lavish hemlock it is traditionally in /etc/passwd

#

also, the "asking for full name and phone number" thing is a debian thing afaik

#

their adduser command

#

useradd, on the other hand, just requires the username

gritty bobcat
#

Can someone help me, I'm trying to install pip for python but it keeps installing to Python 3.5.3 not Python 3.7.7

main olive
#

how are you installing pip?

main olive
#

Anyone know why my .py websockets/asyncio script would work just fine on my local machine; but error out on my aws insance?

#

what sort of error?

fresh saddle
#

@main olive pinged!

main olive
#

hello

fresh saddle
#

How's your day going?

main olive
#

not the right channel for this :p

fresh saddle
#

You asked to be pinged :D

#

I'll probably ask on of the two thousand billions questions I have about Unix as I'm here

#

I tried to look the Linux kernel docs, but they clearly don't intend to have beginner in there, to have a custom filesystem handler (is it the right term?) you need to define some specific methods, but once it is done, how do you hook it up to the kernel? Can you do that at runtime, or you have to edit some files and reboot?

main olive
#

you typically load your driver as a kernel module if it's external

#

ie with modprobe (or plain insmod)

#

this can be done at runtime

fresh saddle
#

Interesting thanks!

cyan wagon
#

@gritty bobcat try installing pip using get-pip.py using python3.7 get-pip.py

modern kestrel
#
if [ "$#" -lt 2 ]; then
  echo "Usage: URL DIRECTORY [--dry-run]"
else
  
  chart_museum_url=$1
  the_path=$2
  pushd $the_path
  
  helm init --client-only
  createHelmTemplate $the_path

  if [ "$#" -eq 2 ]; then
    packageHelmTemplate $chart_museum_url $the_path
  fi
fi
#

Can someone explain to me what this is doing

robust cave
#

@modern kestrel is this part of a bigger script?

modern kestrel
#

Yeah @robust cave

robust cave
#

and you understand everything else except this snippet?

modern kestrel
#

createHelmTemplate() {
  out=$(helm template --namespace test --values=values.yaml --set id=test . )
  echo "${out}"
  helm lint --namespace test --values=values.yaml --set id=test .
}

packageHelmTemplate() {
  chart_museum_url=$1
  echo "Uploading chart to $chart_museum_url"
  helm package . && \
  file=$(ls *.tgz) && \
  curl --data-binary "@$file" "$chart_museum_url" && \
  rm -f $file
}

loginToVault() {
   echo "x"
   export VAULT_ADDR=y
   vault login -tls-skip-verify -namespace=/notprod/hubs/ndap -method=oidc role=oidc_role
}

if [ "$#" -lt 2 ]; then
  echo "Usage: URL DIRECTORY [--dry-run]"
else
  
  chart_museum_url=$1
  the_path=$2
  pushd $the_path
  
  helm init --client-only
  createHelmTemplate $the_path

  if [ "$#" -eq 2 ]; then
    packageHelmTemplate $chart_museum_url $the_path
  fi
fi

robust cave
#

now it makes more sense

#

what do you not understand about the script?

modern kestrel
#

hmmm for the most part yeah my job wasn't to understand the whole thing but i was trying to modify this script so it would take in the chart and path and then execute the functions

#

we got too stuck so our tech lead quickly did it this way

#

but we have no idea what he has done we dont understand bash very well lol

#

and he is too busy to explain ๐Ÿ˜ฆ

#

okay let me think about that for a few minutes please ๐Ÿ™‚

#

what i dont understand there are several things

robust cave
#
if [ "$#" -lt 2 ]; then
  echo "Usage: URL DIRECTORY [--dry-run]"
else

this checks if the number of arguments are less than 2, and if so echo the help message

#

for anything related to helm, the relevant documentation is here: https://helm.sh/docs/
I'm not familiar with it

#
  if [ "$#" -eq 2 ]; then
    packageHelmTemplate $chart_museum_url $the_path
  fi

this then passes chart_museum_url and the_path to packageHelmTemplate if the number of arguments to the script is exactly 2

modern kestrel
#

oooh okay

#

lt means less than

#

or eq

#

awesome thank you

robust cave
#

np

modern kestrel
#

okay

#

i still done understand

#

dont

#

is that

robust cave
#

what do you not understand?

modern kestrel
#

if there is less than 2 arguments it will echo an error but otherwise why does it need the -eq 2

#

there will only be 2 arguments max

#

i dont see why the second if statement is there thats all

#

seems overdone

robust cave
#

I have no idea about the reasoning, but you can pass more than 2 arguments to the script, it just won't execute this block:

  if [ "$#" -eq 2 ]; then
    packageHelmTemplate $chart_museum_url $the_path
  fi
modern kestrel
#

yeah thats why im confused bercause the jenkins file will only pass 2 arguments max

#

maybe this is just an additional precaution

#

but thanks that helped ๐Ÿ˜„

white gust
#

anyone good at linux systemd can help me with this

jerry.service: Failed at step EXEC spawning /usr/lib/python3.8: Permission denied
modern kestrel
#

have you tried chmod +x for your script?

#

just to get anything obvious out of the way ๐Ÿ™‚

white gust
modern kestrel
#

yes

white gust
#

trying

#

nope didnt work

#

still permission denied

modern kestrel
#

Hmmm unsure then sorry you'll have to wait for someone more experience

white gust
#

kk

#

i solved it with the above question's answer

#

using the path from which python3.8

modern kestrel
#

ah okay @white gust so your exec start path file was incorrect?

#

was it the same error, usr/bin?

white gust
#

i was using python3.8 folder at first
the fix was to change it to use the file instead

#

file is the executable

#

like python.exe in windows

modern kestrel
#

ah okay cool

nimble gale
#

is there a waynto copy text to Clipboard that is both Linux & win compatible?

robust cave
nimble gale
#

thanks ๐Ÿค 

humble onyx
#

I have been trying strace to see pipe syscall but it doesn't show up
$strace -f echo hello world | cat

I want to know how piping works. Like two process launched at the same time and echo waits for cat to read from stdin kind of stuff want to know the details but strace doesn't help in that case

main olive
#

observing pipes via strace is difficult due to the nature of pipes

humble onyx
#

thank you

digital haven
#

@main olive fwiw - with rsync is gcp (gsutil rsync) if one has an updated file locally, and the old version on the cloud, rsyncing the data from cloud to local will over-write the local data

main olive
#

interesting

digital haven
#

yeah, just lost an hours worth of gcp api usage

main olive
#

damn, that sucks

#

it's probably a limitation/bug of the faux-FS gcp uses

digital haven
#

yeah i'm not sure ๐Ÿค” screwed me up though, i thought i could use that for syncing data across different systems and users

#

maybe if i push the data first then sync , idk

#

๐Ÿ˜“

lavish hemlock
#

Hi can i set a max login timeout of 10 minutes so when i login, i can do whatever i want and as soon as it's been 10 minutes i get disconnected, no matter what i am doing

#

or maybe 1 minute before it i can run a script that will show i have not much time left

#

So:


System starts timer for 9 minutes and 10 minutes

When the 9 minutes is up, runs a bash script that tells them they have not much time left

When the 10 minutes is up, the user is disconnected
#

How would i do this

fickle granite
#

you might be able to have a program that a) starts when you log in; b) counts down the alloted time; c) kills all your processes

#

but that'd be messy

#

like if you had a cron job running by coincidence, it'd kill that too

#

in theory you might be able to find all your login processes, and then kill them and their children, but ... eww

lavish hemlock
#

I tried making a python script that does it but it just waits for the 10 minutes, and i am unable to do anything, i would need to run it on startup as a background process

fickle granite
#

well you can start it reasonably easily by putting something in your ~/.bash_profile or whatever file your shell reads at startup

lavish hemlock
#

Yes but it will do the same thing

#

there's TMOUT=x
but when you're running python programs it will pause

fickle granite
#

I didn't understand a word of that, tbh

lavish hemlock
#

So i can add TMOUT = 10 to the .bashrc file

#

which will terminate my session after 10 seconds

#

that is what i want

#

but let's say i start a python program and go inactive, it will not terminate my session

#

if i use the w command, it will still show the amount of time i am idle though

#

@fickle granite

fickle granite
#

well I never knew about TMOUT so I don't have anything to say about that

lavish hemlock
#

is there anything i can do about the w command

fickle granite
#

well you could have a python program figure out your idle time, I guess

lavish hemlock
#

if "10.00s" in IDLE

#

i don't think there is a module for it in python

fickle granite
#

I wouldn't be that surprised if there were, tbh

lavish hemlock
#

Ok after a little research, there is a way to do it with the /etc/ssh/sshd_config file itself. All you do is add:

ClientAliveInterval 300
ClientAliveCountMax 0
#

So i guess it's good if you forget to log out of the root user while you grab a coffee :D

fickle granite
#

if that does what you think, then it should be reliable

main olive
#

hi

#

I have this command that prompts for a password after it's entered

#

I tried to use --password-stdin and -p as flags to it to pass the password from a json file using cat <some stuff> | command -p

#

but it doesn't work..

#

how do I pass the password here

main olive
#

anyone?

#

this is what I'm trying to do

#
echo $(gcloud auth print-access-token)\n$(gcloud auth print-access-token) | myapp docker-registry update 22 -u oauth2accesstoken```
warped nimbus
#

Pipe goes to stdin

#

If it needs to be an arg, try using xargs

main olive
#

it's not an arg.. because it doesn't have -p flag or accept --password stdin

#

it prompts for password.. then you type and press enter.. then prompts to reenter password once more

main olive
#

test your output first before piping it

#

I tried this

#

and I am not sure if it entered the password into the prompt.. because I had to press enter both times

#

@main olive

#

you might need to use expect or similar

#

the application might be devouring stdin

#

could you give me an example

#

is it like this

#
#!/bin/bash
export PATH=$PATH:/root/bin/
gcloud auth activate-service-account myid@my-project.iam.gserviceaccount.com --key-file=gcrconnect.json
myapp docker-registry update 22 -u oauth2accesstoken
expect <<- DONE
  expect "Password:"
  send "$gcloud auth print-access-token\r"
  expect "Retype password:"
  send "gcloud auth print-access-token\r"
  expect eof
DONE
main olive
#

@main olive do you think this is ok

#

it didn't work as expected

main olive
#

I tried this: but still having trouble

#
#!/bin/bash
export PATH=$PATH:/root/bin/
gcloud auth activate-service-account myacc-gcr@project.iam.gserviceaccount.com --key-file=gcrconnect.json
auth_token=$(gcloud auth print-access-token)

expect -c "
    spawn myapp docker-registry update 22 -u oauth2accesstoken
    expect "Password: "
    send "$auth_token\r"
    expect "Retype password: "
    send "$auth_token\r"
"
DONE
main olive
#

It works.. I'm done with this problem now

#

can someone tell me how export PATH works and why we need path variables

#

like I want to understand what's going on here

#

with PATH

#

does it overwrite the first one

main olive
#

export PATH just means that PATH is turned into an environment variable, rather than just a bash variable

#

aka all child processes inherit it

#

"does it overwrite" no, because each time PATH is set, the old PATH is included in it

#

aka it appends instead

#

PATH=/root/bin would overwrite, while
PATH=$PATH:/root/bin appends to the old path

prisma lotus
#

hey

#

I've installed ubuntu docker container,
I'm trying to install squid on it

#

and I did

#

but in order to run squid I need to run this command:
systemctl start squid
and as u know u can't run that on a docker container bec of 'systemctl'

#

any ideas ?

jaunty cypress
#

hello i've got a problem

  File "/usr/local/lib/python3.8/tkinter/__init__.py", line 36, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'

i've install python with

dnf install python38
#

how to configure to Tk

main olive
#

@jaunty cypress you tried dnf install python3-tkinter?

#

seems like it's for 3.7, though

#

you might have to build it yourself if you absolutely require 3.8

jaunty cypress
#

oh ok thanks i try

surreal vapor
#

In general, if I import os and then referenced something like chmod how would the interpreter know I am on a Linux box to execute the chmod command in the shell?

fickle granite
#

uh

#

it doesn't "execute the chmod command in the shell"

#

and the interpreter has something built into it that tells it what platform it's running on

terse mesa
#

Hey can I ask something related to vim here?

shy yokeBOT
#

Asking good questions will yield a much higher chance of a quick response:

โ€ข Don't ask to ask your question, just go ahead and tell us your problem.
โ€ข Don't ask if anyone is knowledgeable in some area, filtering serves no purpose.
โ€ข Try to solve the problem on your own first, we're not going to write code for you.
โ€ข Show us the code you've tried and any errors or unexpected results it's giving.
โ€ข Be patient while we're helping you.

You can find a much more detailed explanation on our website.

fickle granite
terse mesa
#

I did ๐Ÿ™‚

main olive
#

@terse mesaunix only allowed here!

main olive
#

@main olive Don't backseat mod, thanks

frigid needle
#

Hello, I need to check if I have PyQt5 installed via which and for some reason it is not showing up although I have it installed. I thought it is because it is pip3 module, but when I do eg. which pyinstaller that one shows up. Does anybody know what could be the reason behind that? To understand, why I would like to prefer which, I am checking more executables and I do that with for loop.

main olive
#

@main olive you're welcome.

#

@frigid needle does pyqt5 even provide executables? what command are you using?

frigid needle
#

@main olive I am using which pyqt5

main olive
#

which only points to the location of executable binaries on $PATH

#

pyqt5 isn't one, it's the name of the pip package

#

you'll need to use something like pip show pyqt5

#

which conveniently returns 1 if the package wasn't found, and 0 if it was

frigid needle
#

Many thanks. I already considered using pip show pyqt5, but wanted to use which, if there was a way.

warped nimbus
#

Which is for executables that are on discoverable on your PATH environment variable

#

If pyqt5 doesnt come with executables then you cannot use which for it

#

It actually does have some executables IIRC, but not one named.pyqt5

#

There's one for generating ui files from python, but I don't remember the name

#

If you want to see if it's installed you could just use pip

#

"Pip show pyqt5"

#

Or you can grep "Pip list"

#

Oh that's been mentioned already

main olive
#

hah you said what I did pretty much word-for-word @warped nimbus

lavish hemlock
#

How can i print a character like โœ“ in the terminal

#

in fact, literally โœ“, that's all i need

fickle granite
#

print('โœ“')

#

NEXT

lavish hemlock
#

that doesn't work @fickle granite

#

if only it was that simple

fickle granite
#

worked for me

lavish hemlock
#

nice question mark in a box

fickle granite
#

try ```py

print('\u2713')
โœ“

#

oh, then your terminial is using a font that is incapable of displaying that charcter.

#

I bet you're on Linux

lavish hemlock
#

yes

fickle granite
#

yep

#

linux sucks for this

#

windows and MacOS are fine

lavish hemlock
#

yeah

fickle granite
#

this has nothing to do with python; it's to do with your terminal app, and/or the font it's using

lavish hemlock
#

i'm using windows's cmd

fickle granite
#

hm, I'd have expected that to do OK

#

๐Ÿคท

lavish hemlock
#

๐Ÿคท

#

๐Ÿ™‚ ๐Ÿ”ซ

#

๐Ÿ’€

fickle granite
#

see if windows comes with an alternative to cmd.exe

#

or try PuTTY

#

kinda dumb using that just locally, but I think you can

lavish hemlock
#

how would i ssh into my subsystem

#

wait give me a sec

fickle granite
lavish hemlock
#

what do you use?

fickle granite
#

Mac

lavish hemlock
#

works in putty

#

ok that's fine, i'll stick with putty

bleak ruin
#

any1 got any idea why is this not working?

#

nothing else is running

fickle granite
#

you have some other process running apt

#

if you're certain that you don't, then I think you can delete that lockfile

#

the file probably contains the PID of the process that created it

#

find that PID, then see if the process is still running

#

if not, it's fine to delete the file

#

if so, you should try to gracefully kill the process

bleak ruin
#

thanks

#

cd.. for linux?

fickle granite
#

I don't understand your question

bleak ruin
#

nevermind

tribal pewter
#

Hi everyone! Iโ€™m using Ubuntu 16.04 and when I open the terminal the username takes too much time to appear, what can I do?

#

What else can I provide?

chilly mural
#

Have you checked if it is system related? ie. slow hardware. What terminal emulator are you using. I'm assuming the default terminal, but that's not a guarentee. Have you searched for this problem on google and tried any of the soltuions provided there? Did they make a difference? or did they fail? What else have you tried

#

Is it just the name that takes time to appear or does the entire terminal stall? how much time is too much time? are we talking seconds, minutes, years. does the terminal work fine after the name appears if it doesn't work while the name loads?

#

To start I would recommend following this https://stackoverflow.com/questions/5014823/how-to-profile-a-bash-shell-script-slow-startup to check if your load times are caused by something in your bashrc file. If you're using the non-default terminal emulator you might look at the FAQ or similar for slow startup questions as there can be workarounds there. LMK if you have any further questions/need help

lavish hemlock
#

why does the terminal sometimes disconnect when i use ctrl+z

chilly mural
#

what do you mean by disconnects? Also ctrl+z is generally used to suspend a proccess in the terminal

#

so if you're running a command and you use ctrl+z it should pause running that command

lavish hemlock
#

well i didn't get disconnected, but the terminal went black and i couldn't do anything else after that

#

not even ctrl+c worked

chilly mural
#

ctrl+d?

tribal pewter
#

@chilly mural
Well thank you very much! I am not the only using that computer and turn out somebody created a conda enviroment, I followed your advise about the .bashrc timing so:

Before:

chilly mural
#

Conda will do that XD. NVM is also a common offender. I'm having ~.5s delays from bash-complete+/NVM that I'm working on solving. LMK if you have any other bash related questions

tribal pewter
#

time source .bashrc

real 0m5.263s
user 0m5.770s
sys 0m2.011s

then i look for the bashrc and deleted the conda init part:

`#Anaconda PATH
export PATH=~/anaconda3/bin:$PATH

>>> conda initialize >>>

!! Contents within this block are managed by 'conda init' !!

__conda_setup="$('/home/manuel/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/manuel/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/manuel/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/manuel/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup

<<< conda initialize <<<`

After:

real 0m0.093s
user 0m0.078s
sys 0m0.016s

Then I check if everything was working fine and it did!

@chilly mural I checked in Google but I did not find an answer before

lavish hemlock
#

What is the recommended directory to store files in, besides the home directory?

chilly mural
lavish hemlock
#

Thanks @chilly mural

chilly mural
#

Yep, for the most part you'll wanna keep files in their respective places in the fs and everything else goes in the user's space. There's more to it than that, but that's what questions are for.

thorn jungle
#

I want help
I have a UNI project due to lockdown
Built a Cloud Security with face recognition
Can you please help me out with some suggestions?

bleak ruin
#

anyone knows how to use screen?

main olive
#

@bleak ruin "reddit karma farming bot"... really?

#

!rule 5

shy yokeBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious/inappropriate or be for graded coursework/exams.

bleak ruin
#

was trying to fix the problem because I couldnt run anything

#

even for installing python

main olive
#

not sure i follow

#

botting to "farm" reddit karma is against reddit's ToS

#

it seems pretty clear that's the reason you installed linux in the first place

digital haven
#

just using ls with google cloud and on my systemls gs://blah/* didn't work, whereas on another the glob * did work. If I leave the glob off then I get the same output as them.
Just wondering why that might be , not sure where I'd start with considering it

main olive
#

@digital haven probably something to do with how shells expand globs

digital haven
#

@main olive bash vs zshell perhaps? hrm... maybe i'll look into it later

tidal lark
#

@main olive are you there?

main olive
#

yes? hello

tidal lark
#

I'm having problems with a server I use. The server has Ubuntu 18.04 and the problem is that some processes sometimes just get killed. It is configured with 256 MB of RAM so I don't know if that is the problem. On it, it's just a headless chrome selenium session that runs ( currently manually ). However, sometimes it works just fine and it gives me the data, sometimes it takes really long and eventually crashes and sometimes the process just gets killed before it does anything. Any suggestions?

main olive
#

what does the process output when it crashes?

#

256M might be a problem if you're doing selenium

#

try adding swap

tidal lark
main olive
#

hmmmm, not too much info here

#

I think you're onto something with the memory, though

#

add a gigabyte of swap and see if it crashes then

tidal lark
#

Do I have to configure it on the server hosts site then?

main olive
#

no, no, this is locally

tidal lark
#

Ok I will try that out, thanks

#

But just for the record: The problem is the RAM then, right?

main olive
#

easiest is to fallocate -l 1G /root/swap

#

and then mkswap /root/swap

#

and finally activating it: swapon /root/swap (this step doesn't persist and has to be done on each reboot unless you add it to /etc/fstab)

#

and see if free -m shows the additional gig of swap

#

and re: is it RAM

#

not sure, but this will help narrow it down

tidal lark
#
swapon: /root/swap: insecure permissions 0644, 0600 suggested.
swapon: /root/swap: swapon failed: Operation not permitted
main olive
#

chmod 600 /root/swap then

tidal lark
#

It gives me this error i.d it is a rented server

main olive
#

you seem to be root, so it shouldn't matter

tidal lark
#

Even with 600 I'm prohibited and that's what free -m says:

root@noez6414:~# free -m
              total        used        free      shared  buff/cache   available
Mem:            256         104         100           1          51         152
Swap:         16383           0       16383
main olive
#

oh, wait

#

you already have 16 gigs of swap

#

so memory ideally shouldn't be an issue

tidal lark
#

Do you know what else could be the problem with selenium? I thought it only could be the RAM because sometimes it works fine

main olive
#

no idea, sorry, i personally haven't touched selenium at all

tidal lark
#

Okay but thanks for your help

#

Btw @main olive , I'm planning on switching to linux once the LTS 20.04 gets released in a few days

main olive
#

nice! good luck

#

hit me up if you have any issues

nimble gale
#

Is there some way to place Console history INTO a Text File? Would love to do that.

#

on Ubuntu, how would I place Console/Terminal history into a Text file please?

nimble gale
#

apparently its easy... never hurts to ask though,.

main olive
#

history > file.txt ?

#

@nimble gale

nimble gale
#

yeah, natureally

main olive
#

i mean, that's the actual command

#

history

#

and output it to file.txt with the > redirection operator

hard perch
#

I've got weird errors from both os.system and subprocess.run trying to run commands

#

subprocess.run first:

#

I've got this line: py out = subprocess.run(['exiftool', cPath], cwd='/root/TxtToSL_Online/engine/', shell=True, text=True, capture_output=True)

#

fails to run, stderr: Data_TxtToSL/cache/bsl/words/test.mp4: exiftool: command not found

#

but both that file, plus the exec (exiftool) exists

main olive
#

have you tried the full path to exiftool?

#

@hard perch

hard perch
#

Let me try

#

oh huh yeah it's in a weird location

#

/usr/bin/vendor_perl/exiftool

#

trying

#

okay so now it doesn't error

#

but it doesn't think i'm passing any args?

#

Fyi this is cPath

#
cPath = 'Data_TxtToSL/cache/{}/words/{}.mp4'.format(lang.lower(), word.replace(' ', '-'))```
#

okay wow it works!

#

i just replaced the array of args to just a string

chilly mural
#

hey @main olive you stil on?

digital haven
#

is it possible to have something along the following lines

git add blah
msg = "something here

multiline message"
git commit -m $msg

i'm not sure if commit can accept multiline stuff likethis

chilly mural
#

yes commit can handle muti-line comments.

main olive
#

@digital haven try git commit without -m or the message and see what happens ;)

#

@chilly mural I'm here, what's up

digital haven
#

@main olive yeah i wanted to commit from a script though

main olive
#

sure, should still work

#

on the off chance it doesn't, replace EDITOR with a function which returns whatever your message is in the script

digital haven
#

if there's no message how will there be a message ๐Ÿค” seems a bit zen for me

main olive
#

hacky, but works

#

i think

digital haven
#

by from a script i mean - i will not type the message, the commit message will be scripted

main olive
#

pure speculation tbh

digital haven
#

fair, i don't think that it works

main olive
#

oh, right, it needs to write the contents to a temporary file, not return the message

digital haven
#

yeah, i wanted to write a multiline commit message from a script

#

single line is fine, but not sure how to do multi

#

just realised i had space around = and it's shell, let me check without

#

seems not

#
mkdir testing
cd testing
git init
echo "this is a file" > something.txt
git add something.txt

msg="this is a test

commit message"

git commmit -m $msg
#

that's the gist of it, i'll have to stick to one line

main olive
digital haven
#

that's not from a script tho

main olive
#

that really shouldn't matter

digital haven
#

it shouldn't

main olive
#

it doesn't

digital haven
#

i tried one line with \n and it didn't work

main olive
#

you need to insert actual newline characters, otherwise nothing will parse \n

#

that's why I did $'\n'

digital haven
#

hmm ok

main olive
#

shell parses that into a newline character for me

digital haven
#

let me try that, thanks

main olive
#

also, in your script

#

in the commit line (the last line), try "$msg" with the quotations

digital haven
#

i always forget when i should/shouldn't quote vars

#

or maybe the advice is "always"

main olive
#

you always should

digital haven
#

๐Ÿคฆโ€โ™‚๏ธ

main olive
#

unless you know you shouldn't

digital haven
#

fair, i don't use bash enough

main olive
#

like when you're passing a string as separate flags / arguments

digital haven
#

seems the way you did it works, i can't get others to though

#

all good, thanks

chilly mural
#

hey xx, I wanted to know if you had any advice on improving terminal launch times. I've got a couple of things in my .bashrc that slow everything down. NPM, bash complete, and some scripts I'm sourcing. My intuition says to lazy load them, but I donโ€™t know if you can do that without using a subshell which kind of defeats the purpose. Iโ€™ve read about wrapping them in functions so they load when theyโ€™re called. But then you'll have load times when you start them, which is better than every terminal instance. Is there another solution that loads then when there terminal starts, but doesnโ€™t stall the terminal while the rest of the script is loading?

main olive
#

@chilly mural you know, I was literally just thinking about this the other day. I've got loads of crap in my rc that slows down shell execution on startup. These are mostly things that would load by the time I navigate to the correct directory anyways to utilise them, so it doesn't make sense that my entire shell spawning stalls while they load, especially if I eventually don't even end up using them. I've been devising a method to load them in the background, only blocking if you call something which relies on a thing which hasn't managed to load in the background yet (which I don't imagine would happen very often, but might still do in certain scenarios). I'll let you know if I've come up with something functional

#

I'm sure something like this already exists in some form, but I haven't been able to come up with the correct terms to find it on Google

digital haven
#

"trickle load" or something

#

like how some backup systems work

chilly mural
#

I've done some extensive googling and couldn't find anything. Some people were talking about moving things from rc files to .profile, but I don't understand the difference between login/interactive and non-login/non-interactive shells to understand the value*

hazy stirrup
#

how i can grep an string if he is seperated randomly

he
llo
#

but i need grep "hello" file

#

without regex

digital haven
#

@hazy stirrup if that's the input file, what would be the output file from your grepping

lavish hemlock
#

Can you auto fill passwords when changing user with su (username)

#

something like su root -P rootpassword

fickle granite
#

dunno what you mean by "auto fill"

#

surely you don't want to type your password on the command line, along with the command and its options

#

regardless of whether you want that, you can't do it

lavish hemlock
#

okay

#

does ssh support security key authentication

#

like physical keys

#

@fickle granite you're the only person i see in here, all the time ๐Ÿ˜„

fickle granite
#

and I'm only here a few hours a day

#

I'm 95% sure ssh does work with physical security keys, but I don't know the details.

#

I'm 90% I use that support every workday of my life in fact

#

we use YubiKeys for something; I assume ssh is involved ๐Ÿ™‚

lavish hemlock
#

@fickle granite Do you think they are useful? I got into a heated argument about them being useless and that a normal usb or phone is just as good

#

But i don't think that's true. Btw if you find out how to use them for ssh authentication please let me know ๐Ÿ™‚

fickle granite
#

I can't honestly say they're useful because I don't have real data. They sure feel useful

#

The one I have for work couldn't be easier to use: it's small enough that it fits into a USB-A slot, and barely protrudes; a bunch of times per day I just touch it, and that's it.

#

I have one on my keychain for personal use, and once in a while when I log in to google or github or whatever, from a new machine, I have to stick that into the slot and touch it. I could just as well use the 2fa app on my phone for that, so ... ๐Ÿคท

lavish hemlock
#

๐Ÿ˜„

#

rm -rfed my entire box

#

oh yeah, they are so nice to have just press a button and you're done

main olive
#

does ssh support security key authentication
@lavish hemlock SSH supports PAM, which in turn supports anything as long as someone has written a library for it - fingerprints, anus prints, password = username backwards, etc

#

although I'm not sure you even need PAM, doesn't SSH come with GPG support out of the box? (which most physical keys do)

muted granite
#

How can i make my python script into a desktop icon?

main olive
#

you need to create a .desktop file which points to it

muted granite
#

thank you

#

do python scripts need the terminal statement to be true?

#

i can't get it launch

main olive
#

post your .desktop file

muted granite
#

[Desktop Entry]
Name=Face Scan
Version=1.0
Icon=/home/homelander/Attendance/idicon.ico
Exec=python /home/homelander/Attendance/GUI.py
Path=/home/homelander/Attendance/
Terminal=false
Type=Application

muted granite
#

how do i know what version to put???

lavish hemlock
#

How do you make su command ask for google-authenticator code?
Since i have it installed

fickle granite
#

that's a whole big can of worms

#

if you're using Linux it might be in the "pam" stuff, although I haven't thought about this for years, so that might be outdated

lavish hemlock
fickle granite
#

only vaguely

#

it looks like it might be relevant, but that's all I can say

#

fiddling with that file is probably dangerous; if you mess it up, you might lock yourself out of your own system

lavish hemlock
#

Failure is the key to learning :p

fickle granite
#

there's something to that ๐Ÿ™‚

lavish hemlock
#

apparently adding to the sshd config: Match User root
crashes my VM

lavish hemlock
#

Hey guys :) Any other known ways of moving to root user without su / sudo ?

main olive
#

"moving to root user"? like privilege elevation?

lavish hemlock
#

yes @main olive

#

without direct root login

main olive
#

hello

#

I mean, there's doas, but that's about it @lavish hemlock

#

can I ask a nginx question here

#

aka webserver questioj

#

!ask

shy yokeBOT
#

Asking good questions will yield a much higher chance of a quick response:

โ€ข Don't ask to ask your question, just go ahead and tell us your problem.
โ€ข Don't ask if anyone is knowledgeable in some area, filtering serves no purpose.
โ€ข Try to solve the problem on your own first, we're not going to write code for you.
โ€ข Show us the code you've tried and any errors or unexpected results it's giving.
โ€ข Be patient while we're helping you.

You can find a much more detailed explanation on our website.

main olive
#

maybe someone knows how to fix

#

I mean

#

the error is pretty self explanatory

#

there's no such config option as server_name_server_blah

#

this is it

#

I access it by: sudo vi /etc/nginx/sites-enabled/flask_settings

#

@main olive if I may ask

small sparrow
#

every time i ctrl+z out of a process, it spits out a seemingly random integer in those brackets

#

just curious as to what it means

main olive
#

@small sparrow job id

#

do jobs

small sparrow
#

ah ok

main olive
#

so you can do something like disown 6 to disown a job

small sparrow
#

whats the difference between a job and a process?

main olive
#

jobs are just processes tied to a specific shell instance

small sparrow
#

ohhh ok

#

so a job is something that takes up a terminal session

#

or that normally would without a process manager

lavish hemlock
#

Has anybody here used KiTTY

#

It doesn't seem to work with google-authenticator/PAM auth, when prompted for the verification code, it says something about attempting automatic.... something

#

Which is not what i want

restive helm
#

When I try to run a python script on my Linux 18.04 VPS it just spams the first print....

When I do this on my Windows10 64x machine, it works, with the exact same files...

I thought this might be a permission thing, since it uses a geckodriver, so I changed the permissions: it spams way slower, but still spams the first command/print...

#

Does anyone know how to fix this? Has anyone had this before?

main olive
#

@restive helm can't really help you if we can't see the code

remote tapir
#

can i record both sounds from the monitor and microphone?

muted granite
#

Can someone help me use pyinstaller on linux?

muted granite
#

its not creating an executable file for me on my linux system

lavish hemlock
#

Hi i need help, i pointed ForceCommand to a script that echo's "hi", but when i login it closes my session immediately

wintry totem
#

I have intel-mkl problems executing some python libraries on manjaro and they are getting annoying. Does anyone know if this is a general common problem to which there is a known solution?

lavish hemlock
#

Here's a little neat bit of code for you all

#
#!/bin/bash
function ufwAdditional {
  while true
    do
      read -p " Enter the port you want to open (type 'done' to exit) 0-65535: " Port
      if [[ ! "$Port" =~ "[Dd][Oo][Nn][Ee]" ]]; then
        ufw allow $Port
      else
        exit 1
      fi
    done
  echo finsihed2
}

ufwAdditional       
echo hi
fickle granite
#

be easier to just hit up-arrow

lavish hemlock
#

i guess

stark thorn
#

hey im in the 'interative shell zsh' and i literally cant do anything

#

everything is "command not found"

#

how do i exit this and go back to my normal terminal

#

even the command they're telling me to use to update zsh isn't a valid command LMAO

#

i typed out exit and im stuk at the process completed

#

it wont let me do anything

#

stuck*

halcyon scarab
#

guys my bash says (base)

#

is that a problem

#

I googled a found out that it is becuase of the anaconna environment

stark thorn
#

okay nvm i fixed it

valid wasp
#

@velvet fulcrum you can either start a new terminal or try "deactivate"

lavish hemlock
#

Check if your password has been compromised!

#!/bin/python  
import hashlib
import requests
import getpass

hash=hashlib.sha1(getpass.getpass().encode("utf-8")).hexdigest().upper()
head,tail = hash[:5],hash[5:]
url='https://api.pwnedpasswords.com/range/'+head
res=requests.get(url)
if not res.ok:
        raise RuntimeError('Failed to fetch "{}": "{}"'.format(url. res.status_code))
hs=(line.split(':') for line in res.text.splitlines())
count=next((int(count) for t,count in hs if t==tail),0)
print("Hash: ",hash,"\nLeaks count: ", count)

Come on people

fickle granite
#

there are only slightly over a million five-hex-digit hashes

#

yet there are hundreds of millions of computer users on the planet, presumably with almost that many unique passwords

#

oic, that returns a whole long list

surreal drift
#

hey I need help with creating a script that add new users please

fickle granite
#

yeah!

#

fire away

#

now of course this is a Python discord, and I'll probably wind up encouraging you to write a python script instead of a bash script

#

@surreal drift this

lavish hemlock
#

Something like this?

import os
name = input(str("What user would you like to add? "))

os.system('adduser {}'.format(name))
fickle granite
#

might's well write a bash script

surreal drift
#

They have asked you to script an automated solution which periodically checks for new user information files
and adds users. Results should be documented in a separate time-stamped log for audit purposes.

vestal turret
#

Be carefull with something like this, running unsanitized input

lavish hemlock
#

I don't understand, sorry

surreal drift
#

it has to be in bash script

vestal turret
#

You wouldn't want someone to input username; delete the entire system command into that

lavish hemlock
#

You can do an ls to see files

fickle granite
#

@surreal drift It has to be bash? Is this homework, or a job interview question, or something?

vestal turret
#

python has it's own ways to deal with the filesystem rather than ls

lavish hemlock
#

@vestal turret It's simple. you don't give out sudo permissions.

#

You could create a script to see if there is new files compared to when you last ran the command, maybe?

surreal drift
#

assignment for uni

fickle granite
#

๐Ÿ˜ฆ

lavish hemlock
#

If you count the number of files in the user's directory, you can store that number and then check again, if the number doesn't match, do something...

vestal turret
#

This is a server for python though,

lavish hemlock
#

^^

surreal drift
#

it is python too

frank thunder
#

i don't even know if you need a specific kind of usb or not im just tryna be safe about it

vestal turret
#

Shouldn't be a problem

warped nimbus
#

Yeah it's fine though kind of a bad deal considering it's USB 2.0

#

If you're gonna buy a flash drive may as well buy one that will be more useful for other things down the road

frank thunder
warped nimbus
#

It doesn't matter for installing linux really

#

But if you are gonna use the flash drive for other things then you'll thank yourself for having usb 3

frank thunder
#

yeah i have nothing else planned that im going to do with it but i think imma go with the usb 3 just for futures sake

warped nimbus
#

To answer your question: yes, I do think that one is a better deal.

frank thunder
#

good because i defo did not impulsively order it for pickup a few minutes before you answered also the questions were probably dumb but thank you for helping

velvet fulcrum
#

@velvet fulcrum you can either start a new terminal or try "deactivate"
@valid wasp ?

main olive
#

hello

#

anyone here using vim?

#

as their python ide

surreal vapor
#

I have, but I prefer gedit on Linux and PyCharm on Windows.

halcyon scarab
#

how do i check if i am using anaconda for vs code?

#

so that I can conda install for my python and not pip install

#

sorry if this was a noob question but I am 2 days old in linux

#

:p

white gust
#
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python3.8'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3.8'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.executable = '/usr/bin/python3.8'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/usr/lib/python3.8/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007ff4bdedd740 (most recent call first):
<no Python frame>

Tried reinstalling python after ubuntu reinstalled since a module is broken but now whole python is broken

#

any solutions? thanks

lavish hemlock
#

How can i run a certain script when a user logs in with bash --norc --noprofile

#

or disable it somehow

fickle granite
#

modify their login shell to a wrapper you control

valid wasp
fickle granite
#

how would they log in with bash --norc --noprofile anyway?

valid wasp
#

ssh -t username@hostname /bin/sh

#

boom no bash

fickle granite
#

not sure I'd call that "logging in"

lavish hemlock
#

@valid wasp No i want to disable it

fickle granite
#

fiddle sshd to run a wrapper that you control

lavish hemlock
#

Could you elaborate?

fickle granite
#

well ssh is quite flexible

#

you can tell it to do all kinds of stuff

#

permit logins, deny them, require certain kinds of authentication

#

and I'm 98% sure you can tell it to run something other than, or in addition to, whatever command the user has typed

#

you'll have to read the sshd man page for details, because I certainly don't know them

valid wasp
#

what are are needing to accomplish @lavish hemlock

lavish hemlock
#

To force users into bash

#

So the bashrc file is called

valid wasp
#

if you dont want ppl to login and use bash just have a diff shell, like ksh applied to logins

#

so you want users to use bash ?

lavish hemlock
#

Yes

valid wasp
#

but you dont want them to have custom bashrc or custom bash profiles?

lavish hemlock
#

I don't want them to login without executing it

valid wasp
#

with out executing the default bashrc and bash profile or without executing user specific bashrc and bashprofile

lavish hemlock
#

doesn't the default one call for their user one too?

#

i suppose their user one

valid wasp
#

I dont understand the use case. There's a good discussion in that link I posted

lavish hemlock
#

It means whatever i add to a users bashrc won't be called when they login

valid wasp
#

isnt that the point?

lavish hemlock
#

I want a python file to be ran

valid wasp
lavish hemlock
#

Yeah

#

hello guys

#

I've setup the python shell and changed the users shell to it

#

Just wanted to know if there's any way or locally a user could bypass it? thanks :3

nimble gale
#

WHICH is better to do, "pip3 install pygame" or "sudo apt-get install pygame" in Ubuntu?

frank coral
#

I'd say pip install

nimble gale
#

pip3 should guarantee compatibility with Python3 :-|}

#

Anyone have time for a quick voice/screen share test?

#

Are we not allowed to Share screens here? or does someone else have to be present?

main olive
#

ssh -t username@hostname /bin/sh
boom no bash
@valid wasp

#

commands still get evaluated via the user's shell

#

so you're just running /bin/sh via bash

valid wasp
#

doh!

#

(I just cut and pasted that from the seg fault link - they go into details further down agreeing with you)

warped nimbus
#

Trying to get this to work ```bash
git checkout <(git branch | grep -iE '^[ ]\w+/\w+/${1}/.*')

#

I get this error ```
fatal: /dev/fd/63: '/dev/fd/63' is outside repository at '/home/mark/repos/python/bot-pydis'

#

Any ideas why this process substitution is not working?

#

I can just use xargs for now

lavish hemlock
#

Do you ever just wish sudo service life stop was a command

main olive
#

@warped nimbus sure you want to be doing <() and not $()?

warped nimbus
#

You're right

#

I misunderstood the purpose of <()

#

The command doesn't read from files so that's why it wasn't working

lavish hemlock
#

Does PuTTY support coloured emoji's over SSH?

#

When i paste them they just turn into this:

lavish hemlock
#

I see people using custom fonts, but i don't have a graphical interface, only the console ^^

main olive
#

you can tell your terminal emulator to use whatever font

#

your terminal emulator is the "graphical interface"

#

even in a truly non-graphical interface such as a tty, you can still specify custom fonts (albeit probably not ones with unicode support)

lavish hemlock
#

How can i install the fonts in the terminal? @main olive

valid wasp
#

All must knee before my google-fu
/s

#

Everyone can do it!

lavish hemlock
#

I tried that already @valid wasp , It is outdated and doesn't work for me

umbral tulip
#

Uhhh. So I'm a noob. I managed to created a folder called "~" within another folder

#

how do I delete this without nuking my home directory?

#

oh found it, ./~ will do it

lilac talon
#

hello! i want to know is it good idea to generate ctags through all virtual environment

#

44 k lines

fickle granite
#

I wouldn't think ctags would be useful at all in python

lavish hemlock
#

Yea ^

tired relic
#

path+=/some/new/bin/dir && export PATH works but when i restart terminal it does not work anymore

#

im using zsh

dreamy wing
#

yeah you need to add it to your .zshrc file

tired relic
#

i tried that it didnt work

dreamy wing
#

did you use export PATH={yourpath}:$PATH

tired relic
#

yes

#

i used export PATH="$PATH:/home/mabdo/.local/bin"

dreamy wing
#

Have you set zsh as your default terminal, if so and you are in zsh echo $PATH

tired relic
#

yes it ismy default terminal

#

when i add that line to my .zshrc file it doesnt work even without restarting terminal

dreamy wing
#

Yeah, the .zshrc file runs at the start of zsh. It should be permenant after that.

tired relic
#

ok i found something online that seems to work

dreamy wing
#

side note: get powerline10k

tired relic
#

powerline10k?

dreamy wing
#

look it up, if you are interested in looks

tired relic
#

thanks

main olive
#

when i add that line to my .zshrc file it doesnt work even without restarting terminal
@tired relic everything you put in .zshrc gets execute when zsh is started

#

if you edit something in there, you need to either source ~/.zshrc or exit and start zsh again

lavish hemlock
#

i made a script for adding stuff to path lol

#

i kept forgetting the command to do it

#

now i just have to type path

#

how fancy

ember moat
#

Is zsh better than bash? If so, how?

lavish hemlock
#

Idk, i have set my shell to a python program and there doesn't seem to be any method of bypassing it @ember moat

ember moat
#

I made a script for unzipping files with different extensions and it turns out that a very similar thing was in my .bashrc

lavish hemlock
#

why does source .bashrc work but bash .bashrc doesn't?

#

isn't .bashrc just a bash script?

native mesa
#

source <scritp> command u run in the current bash terminal that <script>

lavish hemlock
#

i know

fickle granite
#

"source" doesn't start a new process; instead it modifies the currently-running process

#

bash .bashrc "works", in that the new bash process gets all the customizations, but then guess what -- that new process exits as soon as it's finished reading .bashrc

#

so if .bashrc contains, say echo hello, and you "source" it, it's exactly as if you'd typed echo hello.

#

similarly, if it contains x=zebra, it's exactly as if you'd typed that; which means the shell you're now using suddenly has a variable named x, set to zebra.

main olive
#

Is zsh better than bash? If so, how?
@ember moat "better" is subjective. I like zsh more because it had far wider support for plugins and some of its syntax is more modern, asides other minor details like allowing null bytes in variables (making it entirely plausible to store binary data in variables and not just text)

lavish hemlock
#

@fickle granite But i get errors when running bash .bashrc

main olive
#

yes, because .bashrc is not meant to be run with bash. It's not a script.

#

like the error says:

$ bash .bashrc
.bashrc: line 8: return: can only `return' from a function or sourced script
#

you're not sourcing it...

modern kestrel
#

I've broken my terminal

#

can someone help

#

if i try to use shortcuts

#

ls -(anon):4: command not found: _longopt   โ–‘โ–’โ–“ 1 โœ˜ ๎‚ณ at ops โŽˆ
(anon):4: command not found: _longopt
(anon):4: command not found: _longopt

#

I get this

#

my auto suggest for kubernetes and gi

#

are still working fine its just the bash stuff

#

so confused

#

sudo ap(anon):4: command not found: _root_command โœ˜ ๎‚ณ at ops โŽˆ
(anon):4: command not found: _root_command
(anon):4: command not found: _root_command

#

Same for this

#

cd do_cd:73: bad math expression: operator expected at `tmpcdpath '
_alternative:shift:14: shift count must be <= $#
_setup:64: bad output format specification
_cd:73: bad math expression: operator expected at `tmpcdpath '
_alternative:shift:14: shift count must be <= $#
_setup:64: bad output format specification
_cd:73: bad math expression: operator expected at `tmpcdpath '
_alternative:shift:14: shift count must be <= $#
_setup:64: bad output format specification

#

Same here

#

But some basic stuff still works like cat/nano

fickle granite
#

my guess is that you've got a "prompt command" that is doing something wrong; try echo $PROMPT_COMMAND ; unset PROMPT_COMMAND. If that helps, then you need to figure out how it got set, and how to fix it

modern kestrel
#

that doesnt seem to do anything

#

all i did was accidentally run some weird file accidentally

#

this thing

#

but i dont know how to undo that

#

i'm not even sure what the hell it is

#

sourcing my .zshrc file doesn't help either

main olive
#

have you tried temporarily moving your zshrc?

#

maybe you somehow fucked it up

modern kestrel
#

hey @main olive

#

move it where?

#

like just try without oit

main olive
#

dunno, just like .zshrc.bak

modern kestrel
#

and see if its the issue?

main olive
#

yeah

modern kestrel
#

go so many files here but i changed it and nothing has really changed

main olive
#

you need to restart your shell

modern kestrel
#

yeah its kind of fixed it but now its just shit

#

but if i do ls -[tab]

#

it doesnt give an error

#

now*

#

yeah its a problem with the zshrc thing

#
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

export PATH="/usr/local/opt/terraform@0.11/bin:$PATH"
export PATH="/usr/local/opt/terraform@0.11/bin:$PATH"

if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi

alias k="kubectl"
autoload -U +X compinit && compinit
source <(kubectl completion zsh)
#

these are really the only custom things i have in here

#

plugins=(git kubectl)

source $ZSH/oh-my-zsh.sh

#

export ZSH="/Users/Shahe.Islam/.oh-my-zsh"

#

And these but theyve always been there

#

may just have to reinstall

main olive
#

hmm

#
autoload -U +X compinit && compinit
source <(kubectl completion zsh)

what if you remove these?

modern kestrel
#

weird that worked

#

autoload -U +X compinit && compinit

#

I think this line was messing it up?

#

No idea why i had it in there kubectl seems to be auto completing fine without it

main olive
#

ยฏ_(ใƒ„)_/ยฏ

modern kestrel
#

Oh well, thanks for the help mate! I can get back to looking at stuff in peace

#

๐Ÿ˜„

main olive
#

np dog

simple hornet
#

Is there anyone that could help out with getting AppKit to install? I've tried pip and pip3 but it always returns with the same error. Trying to grab the active windows name

#

Here is the error

main olive
#

@simple hornet macos?

#

the error says it: pkg-config is not installed

#

you probably need to do something like brew install pkg-config

simple hornet
#

yeah macos

#

just got my first mac ever

#

and okay shall try that now

#

@main olive Nope didn't work ๐Ÿ˜ฆ

main olive
#

what does which pkg-config say?

simple hornet
#

/usr/local/bin/pkg-config

main olive
#

hmmm

#

try doing export PKG_CONFIG=/usr/local/bin/pkg-config and then the pip install again

simple hornet
#

@main olive nope same error :/

#

Could it be because I'm using anaconda?

ebon wigeon
#

what should I look at if my qemu keeps getting deadlocked on memory

main olive
#

helb

#
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
fickle granite
#

@main olive I don't know what "snap" is but I'd try doing cd ~ and then trying the command again

#

my hunch is that your current working directory got deleted

#

if I'm right, pwd should do something like this: ```py
:-) 2020-04-28T17:04:45-0700 [x]$ pwd
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

main olive
#

snap is like a package installer

#

pwd for me is just /home/nostra

fickle granite
#

out of ideas, then ๐Ÿ˜ฆ

hallow sail
#

How packages management separate different ubuntu versions?

lavish hemlock
#

I have a small python script, but for the input if i type && echo hi && it will echo hi, how can i stop that?

#

since what it does is os.system('clear')

main olive
#

I'm not sure I understand?

#

I have a small python script, but for the input if i type && echo hi && it will echo hi, how can i stop that?
@lavish hemlock ... don't type that?

lavish hemlock
#

what i'm saying is

#

i can easily type something malicious

#

and it would execute

main olive
#

what is your code?

#

where is the command injection happening?

restive helm
#

Hey guys! Quick question ๐Ÿ™ƒ

I'm using the nohup command to run a couple of my bots 24/7 , is there a way to stop one specific bot that is being ran by nohup?
Like is there a way I can specify a directory where I ran this .py and stop it?

fickle granite
#

not by directory, no -- but I think nohup tells you the "process ID" when it starts. If you still have that, you can do kill 12345 (where 12345 is the process ID)

restive helm
#

Yeah indeed, you can also do ps -ef |grep nohup to see all the nohup processes which are running at the moment @fickle granite

#

which also shows the process ID - but I never know which ID is which .py file

fickle granite
#

sounds reasonable

#

if you're brave, you can poke around under /proc; there's lots of detail in there about each running program. You might find the cwd, and the arguments, and whatnot

#

assuming you're on Linux

main olive
#

@restive helm easy method (that was used commonly back in the day, but is considered "hacky" today): create pid files

#

each of your bot will create a pidfile. For example, bot1 creates /var/run/bot1.pid, which just contains the PID of bot1

#

for example, with sshd:

#

second method, which is a tad bit harder to set up but more modern and beneficial in the long run: Don't use nohup. Set up systemd units.

#

I personally recommend the latter

#

makes everything a bit easier - for example, logging is suddenly very easy, as you can just do journalctl -u bot1 to see what bot1 has printed; starting/stopping bots is easier with systemctl start/stop/restart/etc bot1, you can enable them to run on startup, and so on

fickle granite
#

@main olive hardcore ๐Ÿ™‚

restive helm
#

If I'm correct, this isn't the process ID for that directory right?