#unix

1 messages ยท Page 47 of 1

molten wedge
#

pretty Clever solution

main olive
#

yeah this is pretty standard sqrt algorithm

main olive
#

hey

#

so I'm a bit of a novice programmer, I've done a few small projects, but I would like to take this to the next step. Anyway, I've realized that I'm not using my windows for anything exclusive that is really that important. And I would really appreciate having an easier way of coding in C because codeblocks sucks and other alternatives cost money etc... I was thinking of migrating to Unix

#

done a bit of searching, thought of Ubuntu at first, but it felt to be going the windows route with shift away from open-source and customizability and it had some negative reviews overall

#

then Debian jumped out to me as not having any noticeable disadvantages. I don't mind the delay between updates that much, as long as it is stable and well-secured

#

what do you think? also, I wonder which UNIX distribution is mostly used in companies nowadays. Just so that I can get some practice in, in case I work for that

#

I don't think I'd mind the learning curve for it that much either

molten wedge
#

fedora is one of the most popular ones along with Ubuntu

#

both are extremely stable

main olive
#

cuz different distros do different things
@halcyon patio can you give some examples

#

fedora is one of the most popular ones along with Ubuntu
@molten wedge what do you think of debian

molten wedge
#

if you want to use debian just use Ubuntu

#

never used debian personally, but I loved it back when I had Ubuntu

main olive
#

Alright I'll give debian a try

#

go with ubuntu (for now)

#

you will get to know better things as you go by :)

quaint cave
#

umm i need help installing FFmpegPCMAudio on linux
not muuch on google

opaque ginkgo
#

did you do from discord import FFmpegPCMAudio @quaint cave

quaint cave
#

Oohhh

#

Nooo

#

Thanks!

#

Nowhere on Google it said that

past sluice
#

hi i need help regarding custom OS

#

i create my cutome debian os

#

but it only work as a LIVE CD

#

i need to install it properly on my machine

#

what should i change in grub i guess?

molten wedge
#

the default grub always works, if you need dual boot you might have to install os-prober

#

so you don't have to change any configuration files, atleast not for grub.

hard bear
hard bear
#

it's fine...managed to create new database and used 'union' to join them

main olive
#

so, i am new here. i don't know if its the right place to ask this but,


output = subprocess.getoutput("ls")
print(output)```
why am i not getting a output of ls ?
sharp patrol
#

It works for me I don't know why for you it doesn't

#

so, i am new here. i don't know if its the right place to ask this but,


output = subprocess.getoutput("ls")
print(output)```
why am i not getting a output of ls ?

@main olive Try this

import subprocess

p = subprocess.Popen("ls", stdout=subprocess.PIPE)
result = p.communicate()[0]
print(result)
main olive
#

@sharp patrol i get this as a output b'exec.py\npyexec\n'

#

ok this is ok but why this format ?

sharp patrol
#

ok this is ok but why this format ?
@main olive it's bytes you need to convert it to a string

b'exec.py\npyexec\n'.decode("utf-8")
Out[6]: 'exec.py\npyexec\n'

And then split by \n newline

'exec.py\npyexec\n'.split("\n")
Out[7]: ['exec.py', 'pyexec', '']
opaque ginkgo
#

subprocess.run("ls",stdout=subprocess.PIPE).stdout?

main olive
#

thank you @sharp patrol

#

subprocess.run("ls",stdout=subprocess.PIPE).stdout?
@opaque ginkgo i need the output

opaque ginkgo
#

does that not give the output

sharp patrol
#

does that not give the output
@opaque ginkgo For me it does

soft rose
#

I'm writing a CLI that I want to deploy for Windows, Mac and Linux. I'm developing on Windows unfortunately so I've got a password I need stored in env variable as per Corey Schafer's videos. For Mac/Unix the methodology is different, so is there another way of storing passwords safely that we can use across all 3 platforms?

#

e.g. config file

iron valley
#

Anybody have an idea how to map/bind ctrl-alt to altgr on centos7 gnome3?

molten wedge
#

@soft rose look into python decouple

main olive
fallen chasm
iron valley
#

anybody got experience with "xkb" for keyboard mapping a key?

#

@main olive think making a type and symbol with just xkb (w/out xkbmap) will suffice?

#

managed to mess up my whole vm lol

main olive
#

yes as I said you need to careful. You can mess it up

#

but I think search for youtube tutorial on that command

iron valley
#

to be fair mu buddy did the final destruction

#

type "C_A_to_L3" {
modifiers = Control+Alt+Shift;
map[None] = Level1;
map[Shift] = Level2;
map[Control+Alt] = Level3;
map[Control+Alt+Shift] = Level4;
level_name[Level1] = "Base";
level_name[Level2] = "Shift";
level_name[Level3] = "Alt Base";
level_name[Level4] = "Shift Alt";
};

#

I used this to create a new type. but then i added it to a symbols file by key.type (default) and hell broke loose

iron valley
main olive
#

What is the recommended linux directory to keep applications such as discord bots/web scrapers in?

molten wedge
#

you mean in a production environment?

#

/usr/app/ is a nice choice

main olive
#

That looks like a good path

molten wedge
#

make sure you chown it to a non root user

main olive
#

I just did ๐Ÿ™‚

iron valley
#

anybody got an idea what i do wrong?

sinful tulip
#

hey!! does anyone use fusuma?? I need a little help with configs
p.s. fusuma is a program that enables multitouch on your linux

olive jungle
main olive
#

You need to set it to quiet during p10k configure

#

It asks for an option during the configuration

whole granite
#

Anyone in here any good at RegEx? I want to strip off "2796 - " in this string: "2796 - File Name Blah Blah Blah.zip" and others like it but I can't figure it out at all

#

Sorry if this is the wrong channel, it seemed like the best fit

mystic nimbus
#

^\d+\s*-\s* should match 2796 - (as well as 234 - and 981238437-

#

)

winter drift
#

If only people could  in discord...

#

(copy that text and run clippaste [in zsh] in a terminal)

main olive
#

guys how do i install jdk 13

#

its giving me problems

main olive
#

can someone helppppp

#

nvm got it

main olive
#

@main olive are you using ubuntu?

main olive
#

no debian

#

and it works

#

well jdk is installed

#

my project is still f*cked

iron valley
#

Anybody can help me with a XBK keymapping?

#

xkb*

main olive
#

#!/usr/bin/env python3

-- coding: ascii --

import sys, os, time, datetime, signal

"""
The configuration file for runner.py will contain one line for each program that is to be run. Each line has the following parts:

timespec program-path parameters

where program-path is a full path name of a program to run and the specified time(s), parameters are the parameters for the program,
timespec is the specification of the time that the program should be run.

The timespec has the following format:

[every|on day[,day...]] at HHMM[,HHMM] run

Square brackets mean the term is optional, vertical bar means alternative, three dots means repeated.

Examples:

every Tuesday at 1100 run /bin/echo hello
every tuesday at 11am run "echo hello"
on Tuesday at 1100 run /bin/echo hello
on the next tuesday only, at 11am run "echo hello"
every Monday,Wednesday,Friday at 0900,1200,1500 run /home/bob/myscript.sh
every monday, wednesday and friday at 9am, noon and 3pm run myscript.sh
at 0900,1200 run /home/bob/myprog
runs /home/bob/myprog every day at 9am and noon

"""

open the configuration file and read the lines,

check for errors

build a list of "run" records that specifies a time and program to run

define up the function to catch the USR1 signal and print run records

sort run records by time

take the next record off the list and wait for the time, then run the program

add a record to the "result" list

if this was an "every" record", add an adjusted record to the "run" list

repeat until no more to records on the "run" list, then exit

elder estuary
#

I want to decode this string in a way that the delete character will actually work and give me the final string like

b'levelX\rft_wandr\x7f\x7f\x7fNDRel\x7fL0L'

"levelX
ft_waNDReL0L"

is it possible?
"\x7f" is the delete character

main olive
#

Replace that using string replace method

elder estuary
#

I was hoping there was another way

opaque ginkgo
#

whats the usecase?

round sparrow
#

hey guys, I am new this community. I am facing a problem. It is always giving me error when i am trying to install pyaudio. i have python 3.8, 3.7 and 3.6 in my ubuntu 20.04. Is there any way i can successfully install it?

opaque ginkgo
#

what's the error message @round sparrow

round sparrow
#

@opaque ginkgo I will screenshot it .

wintry pagoda
#

Anyone knows, how to stop the process once the user logout from WM (window manager) ?
Yesterday I started my bash script and disown it from the terminal, so that it can run in the background and not stop once the terminal (or bash session) exit. So after i logout from the WM and suspend it for hours, and then again relogin, i saw It was still running.. How to stop the behavior ? Like I want to stop the process once we logout .

round sparrow
#

why this is showing weird things in ubuntu? speech_recognition works fine in windows but in ubuntu this is showing this thing in terminal. what shall i do now?

rugged swift
#

Anyone knows, how to stop the process once the user logout from WM (window manager) ?
Yesterday I started my bash script and disown it from the terminal, so that it can run in the background and not stop once the terminal (or bash session) exit. So after i logout from the WM and suspend it for hours, and then again relogin, i saw It was still running.. How to stop the behavior ? Like I want to stop the process once we logout .
I don't know exactly, but my idea is you can either attach the script process to the WM process using GDB or using inotify to "watching" the WM process.

#

why this is showing weird things in ubuntu? speech_recognition works fine in windows but in ubuntu this is showing this thing in terminal. what shall i do now?
I think the output just inform you that the program attempted to connect into different audio server (ALSA, jack, pulseaudio). Anyway, if the program can listen to any server provided, it is totally fine.

wintry pagoda
#

I don't know exactly, but my idea is you can either attach the script process to the WM process using GDB or using inotify to "watching" the WM process
@rugged swift by WM I meant window manager ( I am using manjaro i3wm here) and there's an autostart feature in i3wm by which you can autostart your program or scripts once you logged in to the window manager... So, I've already written my bash script and added it to the i3 config file i.e.,

exec --no-startup-id /bin/checkRAMSWAP & disown

it will execute the /bin/checkRAMSWAP/ once you log-in to the WM but why it doesn't stop the script once I log out from the window manager ?

rugged swift
#

Because they are separated processes. The script process is not a child of the WM process.

#

Another option is you can get benefit from cron daemon if you are using systemd.

iron valley
#

anybody familiar with "autokey"?

#

Im trying to figure out how to shortcut tilde and pipeline but dont know the key names after alt-gr pressed

vast blade
#

WHO IS USING LINUX MINT CINNAMON

opaque ginkgo
#

do you have a question? @vast blade

molten wedge
#

that was technically a question, albeit one without a question mark. And a bad one too.

nimble ocean
#

I am

#

don't scream at me pls

harsh bison
#

i cant install reflector

#

://

#

pacman -S reflector didnt do anything :((

molten wedge
#

no output?

harsh bison
#

@molten wedge ```shell
tricks in ~ ๐Ÿ v3.8.6
๐Ÿ•™ 10:56:04 โฏ sudo pacman -S reflector
[sudo] password for tricks:
error: target not found: reflector

molten wedge
#

try yay -S reflector

#

i hope you have yay installed

#

weird tho

harsh bison
#
๐Ÿ•™ 11:05:33 โฏ yay -S reflector
 -> Could not find all required packages:
        reflector (Target)

#

xD

molten wedge
#

I'm pretty sure reflector is a part of the official repository

harsh bison
#

yeah i am in the website

#

weird

molten wedge
#

huh looks like there's an error with your db

#

pacman -Syyu

harsh bison
#

yeah i plan to do that

#

xD

#

how the hell

molten wedge
#

are you on arch or manjaro

harsh bison
#

i am on manjaro. does that have anything to do with that?

#

๐Ÿ˜—

molten wedge
#

yeah

harsh bison
#

i see

#

so uhm what to do

molten wedge
#

Arch and manjaro have different repos

#

just the same package manager

harsh bison
#

i thought both pull the same repos

#

now thats new for me :((

molten wedge
#

so uhm what to do
@harsh bison you can git clone their source codes and run makepkg -si inside the cloned directories

#

I'm not sure if it'd work though but it should

harsh bison
#

i seee i will try that then

#

i found a solution on reddit

#

sudo pacman-mirrors -g && sudo pacman -Syy this will fix the problem since it will rewrite the pacman.conf

#

is there any way to automate this:?

molten wedge
#

wdym automate it

harsh bison
#

oh nvm i have an idea

molten wedge
#

just make a script lol

vast blade
#

@opaque ginkgo yes i don't know how to install

#

But nvm

shy yokeBOT
#

Hey @main olive!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

โ€ข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

โ€ข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

main olive
#

def background_process():
try:
pid=os.fork()
if pid>0:
sys.exit(0)
except Exception:
print("Error")
sys.exit(-1)

os.setsid()

try:
    pid2=os.fork()
    if pid>0:
        sys.exit(0)
except Exception:
    print("Error")
    sys.exit(-1)
pid=str(os.getpid())
f=open(".runner.pid","w+")
f.write(pid)
f.close()
#

what does the above program do

opaque ginkgo
#

google fork exec

summer trail
#

@main olive it creates a new process that is completely detached from the parent process.(fork + setsid + fork is a pattern for accomplishing that)

main olive
#

why do we need to do that

#

@summer trail

summer trail
#

Then it writes the process id of the child process to a file, and presumably moves on to doing some interesting work in that detached child process. Now if the parent process is killed, even its entire process group, or if the terminal it was running in is closed, the detached child keeps on running and doing its thing.

main olive
#

ps =str(os.getpid())

#

this gives the pid of what basically

#

@summer trail

#

the child or parent

summer trail
#

The process that runs that function. Which is the child process, because the parent has exited.

#

fork() returns twice, once in the child process (with a return code of 0), and once in the parent process (with a return code greater than zero)

main olive
#

@summer trail I have a a python daemon code will you look at it and help me out

summer trail
#

so each of the ```py
if pid>0:
sys.exit(0)

are exiting in the parent process.
#

I can check it out, but wouldn't it be better to use a library that does proper daemonization?

shy yokeBOT
#

Hey @main olive!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

โ€ข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

โ€ข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

main olive
#

please have a look at this code and can you fix the bugs and create a signal catcher

#

@summer trail

summer trail
#

This seems like a homework assignment. I'm not going to write your assignment for you.

#

!rule 5

shy yokeBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.

summer trail
#

if you have specific questions about how something works, I can try to help things make more sense to you.

main olive
#

I am not asking you to do it for me it is almost complete I am just asking for some general guidance

#

@summer trail please help

summer trail
#

the function to create a signal handler is signal.signal

main olive
#

can you just write the function code

summer trail
#

I'm not going to write your assignment for you.
@summer trail

main olive
#

its not an graded assignment

#

and its just one part I cannot understand

summer trail
#

What's the part you can't understand?

unreal venture
#

I just realized there is this Unix chat.

main olive
#

signal catcher one I send the signal using os.kill(pid,SIGUSR1)

#

@summer trail

#

how do i catch it

summer trail
#

using the signal.signal function that I just pointed you to.

main olive
#

how i am confused

#

i can't understand the documentation please help i am exausted

summer trail
#

the signal.signal function takes a signal number (signal.SIGUSR1 in this case) and a function to call when that condition occurs. The handler function is called with two arguments (the signal number and the stack frame). Most of the time, you don't need these and can just ignore them.

main olive
#

so do i just write signal.signal(signal.SIGUSR1,pid)

#

@summer trail

summer trail
#

no. the second argument is a function that you want to be called when that signal arrives.

main olive
#

what function

summer trail
#

a new function that you write.

main olive
#

that is what i am confused about

summer trail
#

it will be called with two arguments, the signal number and the stack frame, and you can just ignore them.

main olive
#

why would i write a function

#

please can you just show me an example code

summer trail
main olive
#

def receive_signal(signum, stack):
print('Received:', signum)

#

what the hell is this for

summer trail
#

a demonstration of how to define a signal handler. This is one that just prints out the number of the signal it was called with.

#

Like I said, you can just ignore the arguments. You're only registering it for one signal, so it will only ever be called with that one, so you already know the signal number. And it's very rare to ever need the stack.

#

This assignment is asking you to define a new function that will print out the run_list whenever it's called. It will be called with two arguments, because you'll register it as the handler for the SIGUSR1 signal, but you can just ignore the arguments as you don't need them in order to do the work of the function (printing the run list out)

olive jungle
#

ipython

summer trail
#

@main olive your singalDeal function (misspelled) looks like a start at this, but you need to call signal.signal(signal.SIGUSR1, singalDeal) to register it to get called.

main olive
#

cool got it

#

@summer trail just one more question

summer trail
#

shoot

main olive
#

runner.py has to sort the list of timeslot records by time, take the first record
off the list and sleep until that time (use the time module)
โ— then run the relevant program
โ—‹ if it fails add an error record to a "result" list
โ—‹ if it succeeds add a success record to the "result" list
โ— if the record was an "every" record, add it back to the list with the adjusted
time

#

how do i do this according to the current day and time

#

when you see my code run_list is the list which contains the programs that are to run sorted but how do I do this in current day and time

#

@summer trail

summer trail
#

I don't see a way to do this using just the time module. You'll need to use the datetime module, I think.

main olive
#

cool how then

#

the run_list contains (on|every,date,time,cmd)to run it is sorted by day from monday to sunday and time

summer trail
#

create a datetime.datetime - https://docs.python.org/3/library/datetime.html#datetime.datetime - for each of the entries. You can sort datetimes, and you can subtract two datetimes to get a datetime.timedelta that reflects the difference between the two, which has a total_seconds() method on it that you can pass to time.sleep.

main olive
#

Status messages are
โ— a line of text for each time a program has been run or there was an error
โ— a line showing the next time it will be run.
The format for the output lines is:
ran date-time program-path parameters
error date-time program-path parameters
will run at date-time program-path parameters
where words in bold are fixed, date-time is a string in python time.ctime() format,
program-path is the full path of the path

#

we need to output the messages in this format can you help me out here i am stuck on it from days @summer trail

summer trail
#

easiest way is to use f-strings.

#

have you learned them yet?

main olive
#

oh sorry but my run _list contains the day (on|every,day,time,cmd) where cmd is command line argument

#

could you just show me an example code here

summer trail
#

you're not trying to show your run list here, you're trying to show your result list - which is a whole different data structure

#

your result list should contain a "success or failure" flag (which could just be the word "ran" or "error"), and the datetime.datetime at which it ran, and the program that ran.

main olive
#

so how do i do it

#

at 0730 run /bin/touch /tmp/a
at 0800 run /bin/cp /tmp/a /tmp/b
every Tuesday at 1100 run /bin/echo hello world
on Tuesday,Wednesday at 1300,1500 run /bin/date
every Sunday,Monday at 0830,0900 run /bin/rm a b

#

lets assume this is the sample input which I gave you do you still have my code

summer trail
#

yeah.

main olive
#

try to run it in that and create whatever this is asking

summer trail
#

you create an empty list when the program starts up, you append an entry to it for every command that gets run (recording into it the time that it was run, what was run, and whether it succeeded or failed), and you iterate over that list whenever you need to format your status messages.

main olive
#

please just show me example

#

I have been working on this project for days now and I am too tired

#

@summer trail

summer trail
#

no, I've already told you I won't do your homework for you, only give you specific help with specific questions.

main olive
#

please just give the way you would attempt it or would try to attempt it

summer trail
#

no.

#

this community is entirely about helping people to develop their Python skills. Doing your homework would be helping you avoid developing your Python skills. That's the opposite of the entire reason I help out here.

main olive
#

in datetime.timedelta it would use the particular date for eg 13.05.2020 but I just have the day eg Monday,Tuesday and so on

#

@summer trail

#

in my run_list it is formated in such a way (on|every,day,time,cmd)

summer trail
#

now that I think of it, there is a way to do this with just the time module. Sort things by time of day only, without the day of week. Wake up that that time of day, using time.sleep(). When you wake up, use time.localtime() and check the current day of week that it returns. If it's not the way of week you're supposed to run on, move it to the end of the list, and check the next item.

main olive
#

if i write a code and shoe it to u atleast can you tell me wether its right or wrong

summer trail
#

I'm only going to be awake for maybe another half an hour. If you do it before then, then yes.

main olive
#

just give me a minute

main olive
#

I am just getting confused on the fact that my list contains day of week and it is asking for date @summer trail

summer trail
#

the approach that uses the time module is probably what they want you to use, if you haven't learned datetime yet.

#

Sleep until a particular time of day, and when you wake up check if it's the right day of week.

main olive
#

yup

#

how do i do that

summer trail
#

look at the first element of the list, figure out how many seconds from now that will be, sleep for that many seconds, wake up, and use time.localtime() to check the current day of the week and figure out whether it's the right day of week for that event to fire. That works if your list is sorted by time of day

main olive
#

I will show you the list then you just explain to me how to run it by present day and time

#

sorted according to day of week and time as well

#

@summer trail

summer trail
#

I think it's easier if you sort the list by time of day only, ignoring the day of week. You'll need to do some initialization then to rotate the list, so that the first element in the list is the next time of day when an event can run. Then figure out how many seconds from now that time of day is. Sleep that many seconds, and when you wake up check if it's a day that it's supposed to run on. If it is, run the command, and if it's not just move the item to the end of the list and move on to the next.

#

I've gotta go - good luck.

main olive
#

!close

main olive
#

lmao this was not help channel

junior radish
main olive
#

b

frosty ember
#

hello guys they sent me to ask here, i have a little code that uses pyserial to send strings to the arduino i send different strings several times but my arduino only receives the first one i already tested by the serial monitor and it worked so i think it is a problem with my code in python, this is my code

opaque ginkgo
#

wrong channel

#

@frosty ember

frosty ember
#

ok sorry

remote nebula
#

how can i properly remove all python packages from my server via console, im installed a few things incorrectly and that requires me to completely remove it and start over

#

Alright, my server is having issues installing psutil, any ideas as to what i can do to fix it? (ubuntu system btw)

#

it fails to build wheel for it

remote nebula
#

got it to work

#

needed python handlers

main olive
#

how to convert a "0730" into a datetime object

worn apex
#

what exactly does that represent? 7:30 AM on an unspecified date? July 30th?

#

like, the general answer if you know the format is strptime, but there's less information in there than you normally expect from a datetime object no matter what

main olive
#

the current datetoday 0730

#

@worn apex the sting object is date_today=datetime.date.today() +"0730"

worn apex
#

dt.datetime.combine(dt.date.today(), dt.datetime.strptime('0730', '%H%M').time())

#

[strptime with no date components returns 1900-01-01]

main olive
#

if add %S in this would it be a problem

worn apex
#

fine probably, but it's less efficient

#

like this dt.datetime.strptime(str(dt.date.today())+'0730', '%Y-%m-%d%H%M')

#

i'd use combine though, it's more efficient and more clear what's going on

#

%S is for seconds, '0730' doesn't have seconds

#

if you add %S it thinks it's 7:3:0 i.e. 7:03

main olive
#

it should just return the the time such as 0730

worn apex
#

?

#

i'm not sure what from what i've told you isn't enough information for what you need

main olive
#

it gives a name error dt is not defined

#

@worn apex

worn apex
#

i did import datetime as dt

#

sorry i assumed you'd figure that out

main olive
#

yeah got it @worn apex just one more question

worn apex
#

sure

main olive
#

I have create the parsed list how do I implement the sleep function

#

according to current day and time

worn apex
#

figure how many seconds it is between the current time and the intended time, and then time.sleep for that long

#

though... i think real programs like this just usually sleep for one minute every minuet check if the time matches any of the tasks.

main olive
#

do you wanna have a look at the whole code

#

how do I do that for eg its 1400 hours teusday how do i calculate the difference between the current time and intended time

#

@worn apex

worn apex
#

just subtract them

#

use the code we've discussed so far to get a datetime object corresponding to 1400 tuesday [well, can you figure out what day tuesday is?] then, subtract datetime.datetime.now()

main olive
#

the function you gave me produces this

#

current_time-intended_time would result in a negative answer and from the above result how do i just extract time

#

@worn apex are u there

worn apex
#

well, that's because today isn't tuesday

#

you said "the current datetoday 0730" when you were asking earlier

main olive
#

I just want to get the intended time

worn apex
#

use datetime.datetime.today().weekday() to get the day of the week [0 for monday through 6 sunday], and subtract that from the one representing your desired date... you can use modulo operator % to make sure it's positive

#

i told you earlier dt.datetime.strptime('0730', '%H%M').time() to get just the time but you didn't seem to want that

main olive
#

cool

#

how do i run the intended program

worn apex
#

probably os.system or the subprocess module, look at the documentation

#

they've got the arguments separated with comma, so you're better off with subprocess

main olive
#

how do i update KDE for debian? im tryna get 5.20

#

it keeps on giving an error that string type objects cannot be substracted

#

@worn apex

#

i have calculated current time using

#

now=datetime.datetime.now()
current_time=now.strftime("%H:%M:%S")

#

this method

#

@worn apex are u there

#

nice

worn apex
#

you really need to make a full datetime object that has the actual desired day, then subtract

#

not just a time object

#

you have to figure out that "Tuesday" means 2020-10-20

main olive
#

i have done that can you just tell me how to fix this

worn apex
#

then you have a datetime.datetime object that is 2020-10-20 07:30, and subtract datetime.now from it

#

you have? where?

#

i told you you need to be subtracting datetime objects

main olive
#

you wanna take a look at my whole code

#

in that i have created a list which contains days of week

worn apex
#
>>> intended_datetime = datetime.datetime(2020, 10, 20, 7, 30) # you need to figure out a way to calculate this
>>> intended_datetime - datetime.datetime.now()
datetime.timedelta(seconds=33513, microseconds=519156)
>>> (intended_datetime - datetime.datetime.now()).total_seconds()
33508.241577```
main olive
#

and weekday()

#

gives me the current day

worn apex
#

i can look at it i guess

main olive
#

just a sec

shy yokeBOT
#

Hey @main olive!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

โ€ข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

โ€ข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

main olive
#

@worn apex

#

the whole code

worn apex
#

ok like i said

main olive
#

in this code look at line 52-58 and and line 149-155

worn apex
#

you have to get that number 1 referring to tuesday, and subtract datetime.today() from it to find out how many days in the future it is

main olive
#

I have done that

#

I just wanna substract the time and get the seconds

worn apex
#

so, like, (day_list.index("Tuesday") - date_today.weekday()) % 7, is how many days in the future the specified time is

#

...you can't just subtract the time, you have to subtract the date and time, which means you have to actually calculate the date, and no you have not done that in the code.

main olive
#

look at line 58 and 151 I have done that I have already compared the day

#

now on that day i just wanna compare time

worn apex
#

ok but uh

#

it's 10 PM

#

most of the times that day are in the past

#

which means you've either already missed them, or you want to execute them next week

main olive
#

yes

worn apex
#

the reason you got a negative result is because the time is 7:30 AM and it's now 10:24 PM

#

abs can't fix that

main olive
#

i dint get a negative result i got a type error can you fix that for me i am confused

worn apex
#

you got a type error because you used strftime completely unnecessary which i did not tell you to do

main olive
#

please can you fix that for me

worn apex
#

when you used the code i actually told you, you complained about negative results:

the function you gave me produces this
current_time-intended_time would result in a negative answer and from the above result how do i just extract time

#

"just extracting the time" does not make sense and will not solve your problem, I do not know how to make your understand that.

main olive
#

can you just show me the code

worn apex
#

you need to calculate the full date and time of the intended time of running the event, in the future, and then subtract datetime.now() from that

#

...i can't do your whole assignment for you, it's against the rules, and i don't know what part of what i'm trying to explain you aren't understanding

main olive
#

the code is over 200 lines so i am pretty sure you are not doing my assignment for me

#

i am just trying to fix a bug

#

as i do not known the datetime module that properly

worn apex
#

i keep telling you what you need to do i don't get what you don't understand

#

and even if it's not "the whole assignment" i'm worried about doing too much of this part for you because it's the important part.

#

and it's not about the datetime module, it's about understanding what kind of math you have to do - you can't compare the date and time separately, you have to subtract the whole datetime, from the whole other datetime

#

I feel like you're just shutting down and refusing to listen unless I give you code, when I'm trying to walk you through every single step of what you need

main olive
#

sorry can you please have a look at this for me

#

so i finally got the difference between the two between the current and intended time

worn apex
#

ok no i've told you

#

using abs does not fix the negative problem

#

if the answer of intended_time - now is negative, that means your value for intended_time is in the past and therefore wrong

main olive
#

but it clearly worked

worn apex
#

no it didn't

#

that's not going to give you the time you want if you use it for sleep

#

just because it gave you a positive value doesn't mean it's the right value

main olive
#

look at the sreenshot

worn apex
#

BUT IT'S WRONG

main olive
#

okay

#

so it is negative what do i do

worn apex
#

you don't run that one because it's in the past

#

[also what timezone are you in, is it really 13:33?]

main olive
#

australia

#

sydney

#

then how do I run it next week

worn apex
#

do you understand that if you sleep for 2:33:51 from 13:33:51 the time will be 16:07:41, not 11:00:00

#

add 7 days [datetime.timedelta(days=7)] to the intended time... but you need to find the soonest one to sleep for, not the one that's next week.

main olive
#

yeah how do i do that

worn apex
#

you probably need to go through the whole list of rows and calculate the correct datetime for all of them, then sort them

main olive
#

and how do i get the seconds

worn apex
#

wdym

main olive
#

if you look at the screen shot i send you the I have already sorted the list according to the day of week and time

#

and from that list i am selecting the currentday i have to run in

#

I just need to sort the time out and get the closet time to sleep

worn apex
#

well then, just

#

skip that line and move on to the next one

#

if they're all in the past, move to the next day

main olive
#

okay yeah

#

but how do i get seconds and closet time to sleep

worn apex
#

like you said, you already sorted the list

#

so just go through one at a time until you get one at the future

#

ignore the ones that are in the past

main olive
#

what function do i use to get total seconds from the diference

worn apex
#

(intended_datetime - datetime.datetime.now()).total_seconds()

main olive
#

but it gives some 23.56

worn apex
#

also... i've been using datetime.now() in every line, but you should probably get it once at the top so that your program doesn't behave weird if it's very close to the time

main olive
#

@i do not need the microseconds

worn apex
#

you don't not need them, do you? you just do // 1 or int(..all that above..) to chop them off though

#

anyway i need to go for a bit, i'll be back later

worn apex
#

@main olive i'm back

main olive
#

@worn apex are u still there

worn apex
#

yeah but probably not for long, whats up

#

@main olive

main olive
#

hey how do i run a program like this using python

#

/bin/cp /tmp/a /tmp/b

#

@worn apex

#

/bin/echo hello world

#

hey are u there @worn apex

#

@summer trail

worn apex
#

sorry yeah, the subprocess module, i think i mentioned that earlier

#

you can use os.system too, but subprocesss is better

hardy grail
#

os.system is fine unless you need to use the output

main olive
#

how to use fork and exec to run these programs

#

@hardy grail .run() can have capture_output=True

#

sorry i didnt get you

#

how to use fork and exec to run these programs
@main olive fork() and exec() are syscalls

hardy grail
#

right, run is part of subprocess though

main olive
#

@hardy grail oh, I thought you said it the other way around

#

my bad

#

can' t we use fork and exec and wait to run these programs

#

what

#

what are you trying to achieve @main olive

#

I am just trying to run these programs at a particular time like in cron tab but the use of os.system call is prohibited

worn apex
#

the normal way to do this is the subprocess module

#

do they tell you you have to use fork and exec?

main olive
#

yeah they gave us a vauge idea

hardy grail
#

why don't you google how to do what you want to do with the modules you're allowed to use?

main olive
#

I tried that but i dont known the exact keywords that i need to google i am new to this subject

#

look at this this is what i am trying to achieve

#

@worn apex are u there

#

how do i remove the path name from this

#

/bin/cp /tmp/a /tmp/b

#

and then excute the following commands using subprocesses

hardy grail
#

im sure if you looked at the subprocess docs it would become clear

main olive
#

okay

worn apex
#

sorry, i assumed the other users had it handled and i was getting reafy for bed, it's 2am here

#

i'll check in tomorrow morning but i really do have to go to bed for now

opaque ginkgo
#

you dont need subprocess tho

#

for cp

tender plinth
#

Hello , I have a small doubt regarding how linux binaries load shared libraries. Suppose I have a pseudo file system and I want to run a binary which will use the shared libraries specified under that file system , where shud I place the libc and the interpreter so that I can run the binary in the pseudo file system?

#

standard linux binaries load libraries from

    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbcabd19000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fbcabf2d000)``` where ```/lib/x86_64-linux-gnu/libc.so.6: symbolic link to libc-2.31.so``` and ```/lib64/ld-linux-x86-64.so.2: symbolic link to /lib/x86_64-linux-gnu/ld-2.31.so```
#

so shud I place the libc file in the /lib/x86_64-linux-gnu/ as libc.so.6 or as libc-2.31.so?

rugged swift
#

I would recommend to place it into /usr/lib instead of /lib.

tender plinth
#

oh thank u so much

#

so the libc file shud be placed as libc.so.6 or libc-2.31.so.6?

rugged swift
#

It depends on your needs. You can just create a symlink if you need.

opaque ginkgo
#

wait why are you putting libc in /usr/lib

tender plinth
#

can it be done without creating a symlink?

#

wait why are you putting libc in /usr/lib
@opaque ginkgo that was what @rugged swift suggested

opaque ginkgo
#

libc goes in lib

rugged swift
#

Oh, my bad.

tender plinth
#

as libc.so.6 or libc-2.31.so?

opaque ginkgo
#

I think just libc.so.6 should work, but dont quote me on that

tender plinth
#

sure thanks , another thing , file shud go in lib/x86_64-linux-gnu right?

opaque ginkgo
#

yeah

tender plinth
#

thank u very much

#

the same goes with the interpreter too?

#

/lib64/ld-linux-x86-64.so.2 lib64?

opaque ginkgo
#

I think so

rugged swift
#

I would recommend to place it into /usr/lib instead of /lib.
I only gave you a "general" advise IMHO. I don't know what was your case. But Fedora placed libc.so.6 in /usr/lib64. So, I think it depends on what your distro.

tender plinth
#

Im using ubuntu

rugged swift
#

Yeah, sure.

tender plinth
#

ok cool

#

@opaque ginkgo thank u so much it works

tender plinth
#

Hello , I have a bash script which does something like this

#!/bin/sh
cd $PWD
./chall```
 but the issue is , since what Im doing is cd into pwd and then executing the program , when I try to run the script from another directory it doesnt work as the the PWD is different, but I dont want to include absolute path hardcoded as I wish to make the script portable. Is there any work around to achieve this?
opaque ginkgo
timid river
#

guys i'm thinking about moving to manjaro from ubuntu

#

is it a good idea?

main olive
#

can it be done without creating a symlink?
@tender plinth if you have control over executing python itself, you can point it to a different LD_LIBRARY_PATH

#
$ LD_LIBRARY_PATH="/home/xx/libs" python3 script.py
main olive
opaque ginkgo
#

wrong channel?

main olive
#

no

#

okay cool

shrewd thicket
#

aaaaaaaaaaaa
Why is there a unix channel but not win? Finding help for unix is easy, for win impossible

main olive
#

So switch to unix then

#

Simple

shrewd thicket
#

Maybe, but I also use my computer for other stuff then coding

#

also, it was just a channel suggestion

main olive
main olive
#

how do i get the time in next week using time.ctime()

spark veldt
#

you could get current time in seconds, add a number thatโ€™s 7243600 (days times hours times seconds in an hour), then pass that to ctime

#

wouldnโ€™t work in case of leap days or daylight transitions

main olive
#

no for eg time right and day right n0w I wanna get the same time but day next week

spark veldt
#

(also time module is not specific to this channelโ€™s topic)

#

โ†’ yes I understood your question that way, why is my answer wrong? (also I would use datetime and timedelta for this, not time)

main olive
#

yeah I got it thanks one more question

sharp hawk
#

hey everyone , noob question about pip. I installed pip through my linux distros repo, and when I download something through pip it ~/.local/bin. Is there a way to tell pip to install it to /usr/local/bin instead? is that advisable?

main olive
#

why is this not reciving signal

#

@spark veldt please help

harsh bison
#

aaaaaaaaaaaa
Why is there a unix channel but not win? Finding help for unix is easy, for win impossible
@shrewd thicket i think it is easier to find help windows on the internet but slightly annoying on unix

#

so no one ever came up with an idea about making one

shrewd thicket
#

how???

#

Win feels freaking ded , when it comes to developing stuff, it's hella annoying

#

but anyway, I'll ask

gilded basalt
#

You're welcome to discuss it in #community-meta , there used to be a windows channel but it was closed due to low usage

main olive
#

will run at tue oct 20 10:00:00 2020 /bin/hello

#

@summer trail

main olive
#

@main olive what IDE is that??

#

vim?

#

yup

#

damn i want it like that

#

@maiden heath how do ii add like a bitmap font

#

like those pixelated fonts

#

i have gvim

boreal token
#

what advantages does bash have over powershell or cmd?

#

and what advantages does linux have over windows (except that linux is free)?

shrewd thicket
#

I like chocolate ice cream, you like vanilla ice cream

#

I like win, you like linux

#

also, the advantage of bash over powershell and cmd is that it works on linux

#

what a shocker

boreal token
#

๐Ÿคฏ

hollow valley
#

anyone here with a mac / xcode possibly?

#

need some mac help lol

main olive
#

@hollow valley he uses mac @bleak mantle

bleak mantle
#

Hello?

main olive
#

Hi he was asking for mac help

#

I hope he replies lol

bleak mantle
#

Okay. Ping me when you need me. (Hopefully I'll be able to help)

hollow valley
#

sorry I saw this late

#

I managed to fix it! Thank you tho, appreciate the replies sadcatthumbsup

#

@bleak mantle @main olive ๐Ÿ™‚

quick canopy
#

hi, does anyone know how to change the python version? I installed python 3.9.0 for mac from the website, but it still says 2.7.16 when I type in python --version

terse bane
#

try python3 --version

dry osprey
#

Im trying to setup fswebcam on a device running ev3dev(Debian stretch). When I run sudo apt-get install fswebcam I get an error that states "Unable to locate package fswebcam". Is the package no longer available?

opaque ginkgo
#

whats the arch?

#

run apt-get update?

#

bc it exists on the debian packages site

dry osprey
#

Im new to linux and workin with this stuff. I have to use ssh to connect to the device. apt-get update failed with everything. is it a problem with my internet or something?

opaque ginkgo
#

whats the error message?

dry osprey
#

with each file it says "Could not resolve 'link here'"

quick canopy
#

try python3 --version
@terse bane thanks, that goes to 3.9.0, but when I run programs in the terminal I don't think it's using 3.9.0 by default

terse bane
#

typically when a system has multiple installations of python it will differentiate them all in that way. python3, pip3, etc. You have to specify it.

quick canopy
#

oh ok, damn

#

thanks!

main olive
#

like for eg it is Thursday today the date will be 22/10/2020

#

Friday the date will be 23/10/2020

#

Sunday 24/10/2020

#

Monday 25/10/2020

#

and so on

#

and the time in the list of lists should also remain the same

loud star
#

@main olive what do you mean with the current day and time?

#

Can you give me an example of how you would like that sorted?

#

And also if you want it in a bash script or python script

ashen rover
#

I'm trying to install praw using sudo pip install praw to a virtual Linux machine. When I pip install praw on a regular cmd on my PC, it works just fine, but it's not working on the VM. What can I do?

inland gulch
#

Try pip install --user praw in stead of sudo

ashen rover
#
vagrant@precise32:/vagrant$ pip install --user praw
Downloading/unpacking praw
  Cannot fetch index base URL http://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement praw
No distributions at all found for praw
Storing complete log in /home/vagrant/.pip/pip.log
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.0', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 116, in main
    return command.main(initial_args, args[1:], options)
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 147, in main
    log_fp = open_logfile(log_fn, 'w')
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 176, in open_logfile
    log_fp = open(filename, mode)
IOError: [Errno 13] Permission denied: '/home/vagrant/.pip/pip.log'
inland gulch
#

python3 -m pip install --user prawยฟ

#

Does precise32 have python3?

ashen rover
#

Apparently not

#

A new error was returned. Part of it is here.

The program 'python3' is currently not installed.  You can install it by typing:
sudo apt-get install python3-minimal
#

I did previously do this though.

sudo apt-get install python-pip -y
#

I suppose pip is different than Python lol

#

sudo apt-get install python3-minimal ?

inland gulch
#

I'd personally go with a newer Linux lts version, or sudo apt-get install python3 pip is best thought of as a python module, there's one for every python interpreter

ashen rover
#

I see...

#

So you'd do python3 over python3-minimal?

inland gulch
#

Don't know, depends on many other things, if it's development, go with the big one, save the minimal for when resources become an issue

ashen rover
#

It's for a reddit bot. I'm "developing" it I suppose.

inland gulch
#

Try minimal so

#

Nothin to loose ๐Ÿ˜„

ashen rover
#

Can I upgrade from minimal to full at any time using sudo apt-get install python3?

inland gulch
#

Yeah, or better to think of virtual machines as a disposable resource, rebuild it on demand with the packages it needs

ashen rover
#

I see

inland gulch
#

At least that's how I stay sane doin it ๐Ÿ˜ whatever works for you, but try things out and iterate, I see your using vagrant, so you can destroy and rebuild relatively fast

ashen rover
#

This might be a silly question but do I need to keep the VM running for crontab to run it's scheduled commands?

inland gulch
#

Yup, assuming it's the vm's cron

ashen rover
#

ok. Thanks for helping me.

inland gulch
#

You're welcome

ashen rover
#

@inland gulch The tutorial I'm following is saying to put this in my crontab

* * * * * cd /vagrant/RedditBot/Part2/; ./reply_post.py

It's running automatically though.
My friend thinks it's because I need to change it to this, putting python3 in the command.

* * * * * cd /vagrant/RedditBot/Part2/; python3 ./reply_post.py

This brings up another question for me. Since I installed python3-minimal for my python version, does that mean that I should change my command to reflect that?

harsh bison
#

when i did smartctl, it says it passed the disk check

#

but is that reliable?

inland gulch
#

@ashen rover as far as I know, using the pyrhon3 command will work OK whether you install python3 or python3-minimal

shell hound
#

python3-minimal installs the python executable into /usr/bin/python3

inland gulch
#

Alternatively, if you are the author of the reply_post.py file, you can update the files shebang to somethin like #!/usr/bin/env python3 at the first line of the file

#

Cool, @shell hound confirmation that python3 command will work, I've never used a -minimal python ๐Ÿ˜

shell hound
main olive
#

@ashen rover try pip3, pip doesnt work on linux

main olive
#

depends on the distro

#

pip works fine on my machine

#

but yes, the executables might not be there in some cases

#

python -m pip or python3 -m pip should work regardless, though

#

assuming pip is actually installed, that is

main olive
#

Has anyone experienced problems with downloading movies in linux off the web and then transfering them to usb to then play them on a big TV? The files become corrupted in most cases. Tried copying with rsync and regular cp but getting the same result

inland gulch
#

Might not be corrupted, could be an av codec format in the video that the tv doesn't support. Plug the USB into another computer and see can vlc player play the file from the usb

sleek wasp
#

Maybe just watch it on the laptop with hdmi to the TV

wet island
#

anyone know how I can get oracle or somthing similar to access web with my Ubuntu root?

#

@ me if response

sleek wasp
#

nah

wet island
#

not possible?

sleek wasp
#

heh; uhhhh no...

austere jolt
#

oh wait nvm its -S to install

#

my bad

opaque ginkgo
#

exhibit a why apt is better

main olive
#

I much prefer yay/pacman over apt

#

it's just more powerful, plain and simple

molten wedge
#

yay

opaque ginkgo
#

explain how -S meaning install is simple

#

@main olive

main olive
#

what

#

I never said

#

"plain and simple" is a phrase people say

opaque ginkgo
#

or how -Syu somehow means `upgrade|

#

well it's not "plain and simple" then is it

#

wait no

#

I'm high

#

yeah I need clearly need more sleep

patent osprey
#

I prefer yay over apt as well ๐Ÿ™‚

main olive
#

@austere jolt you can search for packages before installing like this
yay package_name

austere jolt
#

?

#

oh

#

i was using -R, forgot that was for uninstall, i wanted to install it

#

used -S next

main olive
#

You are to construct a script that will send a file to a server. You must send the file in the following format. Similar to the Get File task, you will need to send data to the server, however we have introduced a few different steps here, you will need to send compressed data to the server. You will need to ensure that the first line involves SEND string followed by the filename. After the new line, your program should write compressed data over to the server. To compress data, you can use the command gzip and simply pipe data to the command.

SEND <filename>
<compressed file contents>
You will need to use the netcat program for this task. You will need to connect to 127.0.0.1 on port 8787 and send the data to this server. You can assume that the filename will be given as a command line argument.

Example of a sent file

SEND myfile.txt
<compressed contents>
The listening server should receive the content, decompress it and save it locally.

You only need to write the client, not the server

main olive
#

@sharp hollow do you known how to do this

#

I am using gzip but it is generating an EOF error

#

echo "SEND" $1 | nc 127.0.0.1 8787
gzip $1 | nc 127.0.0.1 8787

#

I am trying this but it is generating an eof error

main olive
#

what, exactly, is giving you an eof error

#

post the full error output

#

gzip $1 | nc 127.0.0.1 8787

#

@main olive

#

@main olive are u there

#

yes

#

maybe you should first actually use the gzip command to see what it does

#

because you're currently using it in a manner which is wrong

#

why

#

what do you suggest

fresh saddle
main olive
#

@main olive i'm not going to spell it out for you

#

i've given you hints to lead you on the correct path

#

as we have

#

!rule 5

shy yokeBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.

main olive
#

if you read the gzip module

#

i'm not going to literally do your homework for you

#

it says that you need to use gzip filename to compress the file then why is the given command not working

#

it's not about input

#

it's about output

#

gzip does not output in a manner that is pipeable, not by default anyways

#

like I saud

#

USE the gzip command yourself

#

it should be pretty easy to figure out what's wrong if you do

#

so how do i make it pipeable

#

read the manual

#

I have even tried to redirect the output to a file

#

I read it

#

gzip $1 >myfile.txt| nc 127.0.0.1 8787

#

it gives the same error

#

@main olive

#

@main olive are u there

#

do not spam-ping me or anyone else

#

that's annoying.

#

and will make me less likely to want to help you

#

sorry

#

again

#

USE

#

the tool

#

ANALYSE what it does

#

not blindly trying to redirect or pipe its output

#

it compreses the data

#

how do i make this compresed data to upload on a server

#

yes, it compresses data

#

specifically, it compresses a FILE

#

yup

#

it doesn't, by default, output anything

#

huge fucking hint

#

it gives a .gz file

#

so what about it

#

when you pipe or redirect something, you are simply shoving the output of the program somewhere

#

gzip doesn't output

#

hence

#

you are piping nothing

#

which is why you get an EOF

#

i am getting an error even if i use gzip -c

#

you don't need to use gzip directly with nc

#

don't constrain yourself

#

think outside the box a bit

#

ok, gzip just modifies the original file

#

so what?

#

how do you input files into nc?

#

by piping

#

no

#

then how

#

how do you input files into any program that expects files?

#

regular files

#

not the output of another program, which is what piping would be

#

command line arguments

#

no

#

then how I am not getting your question

#

you tried using it before so you're definitely at least familiar with the concept

#

but you used it in a manner which made no sense

#

how do you input files into any program that expects files?

#

whats the answer of this

#

how do you save the output of a program to a file

#

by writing in it

#

no dog

#

dude I have just started learning this concept

#

i don't get it, you at least know of the concept of redirection

#

yeah okay

#

alright ]

#

cat >myfile.txt

#

you can redirect the output of a program to a file - likewise, you can redirect a file to the input of a program

#

no, not cat

#

program <-> program = needs a pipe
file <-> program = needs redirection

#

cat is a program

#

oh yeah you gave an example of saving the output

#

yeah

#

the reverse also exists, like i said

#

so you are saying

#

something like

#

gzip -c $1>myfile.txt

#

then

#

no

#

stop trying to fuck with the gzip command

#

just gzip [filename] is fine

#

that's it

#

you don't need to try and play with gzip

#

okay cool

#

gzip $1<nc 127.0.0.1 8787

#

no

#

please listen to me

#
  1. stop trying to fuck with the gzip command. no redirection, no flags, just plain old gzip to compress your data IN THE FILE. you don't need to do anything else with gzip
  2. PROCESS TO PROCESS COMMUNICATION REQUIRES PIPES. currently you're using redirection, which is for when you're trying to redirect a file
#

you can add more commands than 2

#

you know netcat accepts pipes, it will also accept a redirection of a file into it

#

gzip $1

#

$1 >netcat 127.0.0.1 8787

#

would thiswork

hard bear
#

Hey I'm trying to use Zeppelin from Amazon AWS but the port forwarding stucks here...no error just stuck

main olive
#

would thiswork
@main olive try it out

#

@hard bear it's possible that the user shell is something which doesn't... prompt for anything

#

can you post the output of the ssh command but with a bunch of -vvvvv thrown in there?

hard bear
#

This is what I get

main olive
#

same command

#

script.sh: line 6: file.out: command not found
gzip: stdin: unexpected end of file
0a1,6

Hello
This is a sample file
lorem ipsum
and such
keep on going
and this should be decompressed full at this point.

#

just with the -vvvvv flag also

#

@main olive that's not how you redirect a file into a program

#

please, research

hard bear
main olive
#

I tried to look it up on internet but did not find any useful article on how to redirect file into a program

hard bear
main olive
#

even if you use netcat 127.0.0.1 8787<$1

#

it does not work

main olive
#

@main olive are u still there

main olive
#

it does not work
@main olive that one should

#

@hard bear yeah, it looks like the session is successfully established

#

which means that the user's shell is something that doesn't prompt for anything

#

You are to construct a script that will send a file to a server. You must send the file in the following format. Similar to the Get File task, you will need to send data to the server, however we have introduced a few different steps here, you will need to send compressed data to the server. You will need to ensure that the first line involves SEND string followed by the filename. After the new line, your program should write compressed data over to the server. To compress data, you can use the command gzip and simply pipe data to the command.

SEND <filename>
<compressed file contents>
You will need to use the netcat program for this task. You will need to connect to 127.0.0.1 on port 8787 and send the data to this server. You can assume that the filename will be given as a command line argument.

Example of a sent file

SEND myfile.txt
<compressed contents>
The listening server should receive the content, decompress it and save it locally.

You only need to write the client, not the server

#

@main olive have a look at this

#

i already saw this

#

what exactly isn't working

#

redirecting it with nc [ip] [port] < [filename] should work

main olive
#

it says no such file exists

#

@main olive

#

of course it doesn't

#

gzip changes the filename

#

i've told you like ten times now

#

actually RUN GZIP

#

and see what it does

#

instead of just blindly trying random shit

#

it changes the filename to $1.gz

#

but how do I write this

#

@main olive

#

what do you mean how

#

that's exactly how you write it

#

or, if you want to be safe

#

super duper safe even

#
"${1}.gz"
#

also i've told you this already

#

but please don't PING ME after every question

#

cool

#

hey it still says no such file

main olive
#

Might not be corrupted, could be an av codec format in the video that the tv doesn't support. Plug the USB into another computer and see can vlc player play the file from the usb
@inland gulch

#

both linux machines play the movie file just fine

#

I don't remember having any issues like that when I used to download movies from within windows

#

problems only started arising when I switched to linux

static cosmos
#

post hoc ergo propter hoc

#

also, what is the filesystem of the usb?

opaque ginkgo
#

it depends

robust cave
#

also, what is the filesystem of the usb?
@static cosmos very commonly either FAT32 or exFAT, if the usb is basically only used for a certain OS then it might be one of these as well:
windows - NTFS
macos - HFS+
linux - EXT2/EXT3/EXT4

tribal isle
#

!accept

static cosmos
#

It wasn't a general question, it was at the person above me

inland gulch
#

@main olive it's a tough one to troubleshoot, couple of questions: does the tv 'recognise/detect/see' the USB drive when you insert it? If so, does it see the video file object on the USB?

pearl owl
#

Can someone help me figure out how to add my Windows Download folder to my Linux Home directory?

inland gulch
#

@pearl owl sent you a dm with some tips

opaque ginkgo
#

@pearl owl wsl?

#

symlink it

#

ln -s /mnt/c/users/username/Download ~/Download should work

barren temple
#

where should i put things served by nginx/uwsgi?

#

๐Ÿ˜„

#

should i make a separate user for them or have my user be part of www group or something

spark mulch
#

seperate user

barren temple
#

how do i mount wsl / as root as a windows drive? I tried sshfs but i couldn't get it working ๐Ÿ˜„ It mounts a remote perfectly, so theres something wrong with my sshd config probably. The error message is just wrong i think. How else can i mount it?

opaque ginkgo
#

you can already do //wsl$/distro_name/

#

and just mount that

barren temple
#

thanks!

#

how do i add it as root? I put \wsl$\root@distro\ and it complains about perms

main olive
#

sudo

#

btw

#

afaik in new insiders version of windows

#

it automaticly mounted

#

you can see it left bottom of file explorer

#

Suggestion: Use Linux not Windows.

barren temple
#

@main olive yeah ๐Ÿ˜ฆ But I want to play games ๐Ÿ˜‰

main olive
#

wine ๐Ÿ˜‰

barren temple
#

how well it works?

main olive
#

idk

#

but it allows you to execute windows apps in linux

#

except

#

UWP apps

#

and league of legends

opaque ginkgo
#

cant you do that already

#

even without the auto mount

barren temple
#

hmm i ended up using vscode remote ssh thing because i couldn't get it working otherwise ๐Ÿ˜„

#

user's fault probably, but i can tinker now as root without using console vim

opaque ginkgo
#

wait for vscode

#

would sudo code . not work

barren temple
#

idk where its installed and it's not in path. Let me see :] I tried to open explorer as root and open /etc/shadow but it didnt let me ๐Ÿ™‚

#

file "opened" up, but it doesn't show contents ๐Ÿ˜ฎ so, nope i guess?

#

also usermod -a grp user shows me usermod help. How is it wrong?

shrewd thicket
#

I installed python3.9

#

and uh, how do I use it then?

main olive
#

in your terminal type python3

#

or maybe python3.9 or python 39

clear narwhal
#

dd\

dusty pecan
#

guys what is the role of a virtual box ?????
when in shifting operating system

barren temple
#

i downloaded manjaro image, but wlan doesn't work and it is too inconvinient to use wired. It is a BCM4352 broadcom thing. Does someone wanna help me get it working from the installation media?

#

idk if my distro choise was any good. I wanted manjaro bcs it's supposedly (?) a rather stable thing and is rolling release.

#

also easy to use is good

barren temple
#

Btw i had a nightmare. On my vps i had no vim or vi, and I had to edit files with nano. I don't like vim, but nano is just too hard.

#

๐Ÿ˜ฆ

narrow kindle
#

I know right? How on earth am I supposed to exit the editor when :q doesn't work?

opaque ginkgo
#

nano is just too hard.
x doubt

main olive
#

@main olive it's a tough one to troubleshoot, couple of questions: does the tv 'recognise/detect/see' the USB drive when you insert it? If so, does it see the video file object on the USB?
@inland gulch

#

The TV does recognise the USB drive, furthermore it plays the movie yet at somewhere around 90% of the play time it bugs, then either starts playing the next file or just stops at all.

#

ffprobe'ing the movie files from the linux machine showed no errors

#

could it possibly be that downloading the same file on a windows machine then transfering it to USB has a higher chance of being successful rather than doing the same on linux?

#

I wouldn't imagine custom linux file flags would interfere would they

#

I tried playing around with rsync and cp both with -a preserve option and without but don't believe those have much impact

barren temple
#

hi levemir

inland gulch
#

@main olive I have seen that issue before, couldn't 'fix' it per say, I located another file source once, and recoded the video another time, and used a different playback device yet another time. What you asking about Windows/Linux probability of success is possible in theory but improbable in practice. You could spend years trying to reproduce/prove such a thing, or you could spend 5 minutes finding a new video source, or a little longer recoding the download with vlc. other things to check 1. whether the USB has a bad sector. 2. the source video have any bad artefacting/visual glitches around the 90% mark (when viewed through the computer that downloaded it or something with more grit than your tv set, e.g. xbox has a vlc app if you have one of them lying around, I'm convinced it would have a fare bash at playing VHS if you beat one into the box), 3. try sudo sync before unmounting the drive after the transfer.

main olive
#

@inland gulch any command line tool for recoding the movie file perhaps?

#

and i will try sudo sync

#

Sometimes I can't unmount the usb even with -f option due to it being busy so I assume sudo sync would also help sort that out

inland gulch
#

Ffmpeg is one of the go-to tools for cli a/v opps. yeah, sudo sync should ensure all read write ops are finished and allow you unmount

blissful sage
#

help!

#

I have update my mac and now i can't run my script through terminal

#

i used brew to manage my python versions

#

im on catalina

#

i think my sym links messed up or something

#

it can't seem to find the ```[Errno 2] No such file or directory

main olive
#

what is unix?

blissful sage
#

it's like mac

blissful sage
#

omg and it's using zsh now too

opaque ginkgo
#

mac, linux, bsd are all unixes

#

its kinda hard to define

#

"I know it when I see it"

blissful sage
#

@opaque ginkgo any experience with symlinks after unix updates >.>

#

brew upgrade didnt help

#

getting a ```Reason: image not found

opaque ginkgo
#

full traceback?

#

i've never used mac though

blissful sage
#
  Referenced from: /Users/asdasdasai/PycharmProjects/ExpFlask/venv/bin/python
  Reason: image not found```
opaque ginkgo
#

oh its a mac specific issue

blissful sage
#

i think it's abrew thing

#

because it upgraded to python 3.9

#

but it's looking for a 3.7 image

inland gulch
#

@blissful sage brew install python@3.7

blissful sage
#

im in the middle of a project and everything

inland gulch
#

Or install pyenv and stop using system pythons

blissful sage
#

i think i might have pyenv

#

gues not

#

which pipenv returns notfound

inland gulch
#

Pyenv, not pipenv

blissful sage
#

installing python 3.7 didnt fix it either

#

oh i do have pyenv

#

but im not that great with sys admin stuff

#

isnt brew supposed to handle all this

inland gulch
#

Looks like a pycharm issue, I'm out, only further suggestion I have is change to use native tools like zsh and vim but that probably doesn't help

blissful sage
#

probably pycharm

#

some venv stuff

#

i guess I could delete and recreate the venv

inland gulch
#

When brew updated your system python it likely blew away your pycharm venv, that's about all I can deduce from what you posted, no idea how to fix that

blissful sage
#

uhhh i think can just recreate

obsidian barn
#

Hello Unix people. I'm hoping I'm in the right place

#

I'm working with a python script that opens a websocket to a js-runtime running in a browser (itself launched by the script). The socket is taking betwen 5 and 10s to open- after it opens it runs perfectly fine. I've had a friend launch the script on their own system and it opens more or less immediately. The code used to work fine- I went away a while and did some other stuff in the project, and now that I'm back the problem has come up from out of nowhere.

The problem, I think, is that my computer is taking its sweetass time to open the socket. I've tried using different ports. I've established websocket connections using other (non-python) tools and they are somewhat faster- but still lagging

#

What reasons could cause a 1 year old iMac to open port/socket connections slowly

main olive
#

arco linux

#

with i3wm

main olive
#

nice

#

is this the preconfigured iso? @main olive

#

no lol

#

@main olive

#

nice

#

what is the blur devilspie?

#

picom

#

its a compositor

#

I never knew you can do that with picom lol

#

i can give u the config if u want

#

if u use picom

#

well do you have your dotfiles repo?

main olive
#

@inland gulch

#

sudo sync is hanging

inland gulch
#

it's more likely processing

main olive
#

Hi

shut tusk
#

hi

solemn ravine
#

hi

warm flax
inland gulch
#

ls /etc/fstab and blkid to work out correct disk uuid

hot quarry
#

I have a bash script like:

python_path= which python3
echo $python_path

if [$python_path != ""];then
echo python is installed
else
echo quitting script: no python installation
exit 1
fi

$python_path logger.py
$python_path target_code.py

#

But it seems like I cant use the variable like a command, why is that

#

In the terminal I can do /usr/bin/python3 logger.py

#

Error:./startup.sh: line 17: logger.py: command not found ./startup.sh: line 18: target_code.py: command not found

summer trail
#

Did you mean to do python_path=$(which python3) ?

#

Currently you're never setting the python_path shell variable.

hot quarry
#

I set it like python_path= which python3 and if I echo python_path it ouputs /usr/bin/python3

inland gulch
#

eval $python_path but that all seems three times more complicated than it need be, a bash script with ./logger.py && ./target_code.py gets it done, no?

merry surge
#

WHAT DO WE DO HERE

opaque ginkgo
#

oh lmao i see

#

python_path= which python3 isn't setting the variable to the result of which python3

#

its setting python_path to empty str

#

and then calling which python3 and ignoring the result, so it still gets printed to stdin

#

then the echo on the next line prints nothing

#

so it should be python_path="$(which python3)"

#

@hot quarry

#

and that's why your current code isn't working

#

because python_path is blank

#

but you don't need it to be this complex in the first place

#

just check if python3 exists using command -v

#

then you can just do python3 logger.py

#
$ cat test.sh
if command -v python3 >/dev/null 2>&1; then
    echo "python is installed"
else
    echo "quitting script: no python installation"
    exit 1
fi

python3 logger.py
python3 target_code.py
$ sh test.sh
python is installed
logger
target_code
main olive
#

Hi,
i want to feed an env var to a command prompt, but I cant find how

#

at least not without writing it to a file in between

main olive
#

it's more likely processing
@inland gulch

#

sometimes sudo sync and umount finish in an instant

#

i clearly finished coppying the files onto the usb and its not open in any file managers

#

confusion

#

why does it hang

barren temple
#

@main olive how about using .env files? python-dotenv package. Is that what you want?

inland gulch
#

@main olive loads of things can cause it to 'hang' apparently depending on your kernel version, speaking of, what kernel and operating system is this on? Examples include: if there is a zombie process holding a buffer it looks like a hang but is simply the sync waiting to free the buffer, some database drivers exhibit this issue. Others reported bugs in the ext4 driver leading to apparent hangs but that the issue goes away if you use the ext2 controller with the ext4 drive. There no end to how far or wide the issue might be.

#

@main olive command $env_var_name

main olive
#

Guess I have to be more specific

#

Consider the python script
a = input('Enter something\n') print(a)

#

now I want to call this on the CLI and output a variable env variable

#

say $HOME

#

I can write $HOME to a file echo $HOME > some_file and then call python3 script.py < some_file and it will print the content of $HOME

#

now, I liked to get rid of that file step in between

#

and $HOME is just an example. I know how to read env vars within python.

inland gulch
#

In bash its export variable='value', in python its os.environ["variable"] = "value", here's the rub, you need to run all your code in a single shell, you cant export/os.envir... in one shell, then read it in another shell, you have to use files for that kind of thing.

main olive
#

You don't get what I want

#

I have a third party program that I have no control over

#

that ask to input stuff when it's started

#

now I want to call it in a way that it reads the input from an env variable

#

like you can do with file input

inland gulch
#

Sounds like a case for bash's 'heredoc', based on your example
python3 script.py < some_file replace < some_file with << EOF current working directory is: $PWD logged in as: $(whoami) Var=${environment_var} EOF the contents between the EOF tags are piped into the program
https://tldp.org/LDP/abs/html/here-docs.html

#

The current working dir and logged in as stuff is just an example