#unix
1 messages ยท Page 47 of 1
yeah this is pretty standard sqrt algorithm
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
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
if you want to use debian just use Ubuntu
never used debian personally, but I loved it back when I had Ubuntu
Alright I'll give debian a try
go with ubuntu (for now)
you will get to know better things as you go by :)
did you do from discord import FFmpegPCMAudio @quaint cave
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?
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.
Hey...how do I append another record to the contents array using dataframe pyspark?
it's fine...managed to create new database and used 'union' to join them
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 ?
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)
@sharp patrol i get this as a output b'exec.py\npyexec\n'
ok this is ok but why this format ?
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', '']
subprocess.run("ls",stdout=subprocess.PIPE).stdout?
thank you @sharp patrol
subprocess.run("ls",stdout=subprocess.PIPE).stdout?
@opaque ginkgo i need the output
does that not give the output
does that not give the output
@opaque ginkgo For me it does
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
Anybody have an idea how to map/bind ctrl-alt to altgr on centos7 gnome3?
@soft rose look into python decouple
@iron valley you can seee xkbmap, but you need to be careful a bit
https://wiki.archlinux.org/index.php/Xorg/Keyboard_configuration
I made a shell file double clickable in mac to open. When i double click it i get an error when i use terminal it works.
script
#/bin/sh
python3 ./main.py
echo "Done"
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
yes as I said you need to careful. You can mess it up
but I think search for youtube tutorial on that command
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
https://unix.stackexchange.com/questions/157834/how-to-bind-altgr-to-ctrl-alt i just cant figure out how to use it properly in a symbols file apparently
What is the recommended linux directory to keep applications such as discord bots/web scrapers in?
That looks like a good path
make sure you chown it to a non root user
I just did ๐
anybody got an idea what i do wrong?
hey!! does anyone use fusuma?? I need a little help with configs
p.s. fusuma is a program that enables multitouch on your linux
never seen this before
You need to set it to quiet during p10k configure
It asks for an option during the configuration
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
If only people could [H[2J[3J in discord...
(copy that text and run clippaste [in zsh] in a terminal)
@main olive are you using ubuntu?
#!/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
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
Replace that using string replace method
I was hoping there was another way
whats the usecase?
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?
what's the error message @round sparrow
@opaque ginkgo I will screenshot it .
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 .
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?
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 usinginotifyto "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.
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 ?
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.
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
WHO IS USING LINUX MINT CINNAMON
do you have a question? @vast blade
that was technically a question, albeit one without a question mark. And a bad one too.
no output?
@molten wedge ```shell
tricks in ~ ๐ v3.8.6
๐ 10:56:04 โฏ sudo pacman -S reflector
[sudo] password for tricks:
error: target not found: reflector
๐ 11:05:33 โฏ yay -S reflector
-> Could not find all required packages:
reflector (Target)
xD
I'm pretty sure reflector is a part of the official repository
are you on arch or manjaro
yeah
so uhm what to do
@harsh bison you cangit clonetheir source codes and runmakepkg -siinside the cloned directories
I'm not sure if it'd work though but it should
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:?
wdym automate it
oh nvm i have an idea
just make a script lol
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:
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
google fork exec
@main olive it creates a new process that is completely detached from the parent process.(fork + setsid + fork is a pattern for accomplishing that)
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.
ps =str(os.getpid())
this gives the pid of what basically
@summer trail
the child or parent
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)
@summer trail I have a a python daemon code will you look at it and help me out
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?
http://web.archive.org/web/20120914180018/http://www.steve.org.uk/Reference/Unix/faq_2.html#SEC16 explains a lot of the other complexities.
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:
please have a look at this code and can you fix the bugs and create a signal catcher
@summer trail
This seems like a homework assignment. I'm not going to write your assignment for you.
!rule 5
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.
if you have specific questions about how something works, I can try to help things make more sense to you.
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
can you just write the function code
I'm not going to write your assignment for you.
@summer trail
What's the part you can't understand?
I just realized there is this Unix chat.
signal catcher one I send the signal using os.kill(pid,SIGUSR1)
@summer trail
how do i catch it
using the signal.signal function that I just pointed you to.
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.
no. the second argument is a function that you want to be called when that signal arrives.
what function
a new function that you write.
that is what i am confused about
it will be called with two arguments, the signal number and the stack frame, and you can just ignore them.
def receive_signal(signum, stack):
print('Received:', signum)
what the hell is this for
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)
@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.
shoot
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
I don't see a way to do this using just the time module. You'll need to use the datetime module, I think.
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
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.
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
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
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.
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
yeah.
try to run it in that and create whatever this is asking
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.
please just show me example
I have been working on this project for days now and I am too tired
@summer trail
no, I've already told you I won't do your homework for you, only give you specific help with specific questions.
please just give the way you would attempt it or would try to attempt it
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.
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)
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.
if i write a code and shoe it to u atleast can you tell me wether its right or wrong
I'm only going to be awake for maybe another half an hour. If you do it before then, then yes.
just give me a minute
I am just getting confused on the fact that my list contains day of week and it is asking for date @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.
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
I will show you the list then you just explain to me how to run it by present day and time
the sorted list
sorted according to day of week and time as well
@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.
!close
lmao this was not help channel
Hey guys how do I use setup.py with bdist_rpm to specify the prefix used? The docs (https://docs.python.org/3/distutils/builtdist.html) indicate you can change this prefix but I can't figure out how. I want it to use /usr/local/lib instead of /usr/lib
b
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
ok sorry
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
how to convert a "0730" into a datetime object
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
the current datetoday 0730
@worn apex the sting object is date_today=datetime.date.today() +"0730"
dt.datetime.combine(dt.date.today(), dt.datetime.strptime('0730', '%H%M').time())
[strptime with no date components returns 1900-01-01]
if add %S in this would it be a problem
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
it should just return the the time such as 0730
?
i'm not sure what from what i've told you isn't enough information for what you need
yeah got it @worn apex just one more question
sure
I have create the parsed list how do I implement the sleep function
according to current day and time
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.
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
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()
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
well, that's because today isn't tuesday
you said "the current datetoday 0730" when you were asking earlier
I just want to get the intended time
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
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
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
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
i have done that can you just tell me how to fix this
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
you wanna take a look at my whole code
in that i have created a list which contains days of week
>>> 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```
just a sec
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:
ok like i said
in this code look at line 52-58 and and line 149-155
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
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.
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
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
yes
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
i dint get a negative result i got a type error can you fix that for me i am confused
you got a type error because you used strftime completely unnecessary which i did not tell you to do
please can you fix that for me
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.
can you just show me the code
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
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
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
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
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
but it clearly worked
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
look at the sreenshot
BUT IT'S WRONG
you don't run that one because it's in the past
[also what timezone are you in, is it really 13:33?]
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.
yeah how do i do that
you probably need to go through the whole list of rows and calculate the correct datetime for all of them, then sort them
and how do i get the seconds
wdym
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
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
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
what function do i use to get total seconds from the diference
(intended_datetime - datetime.datetime.now()).total_seconds()
but it gives some 23.56
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
@i do not need the microseconds
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
@main olive i'm back
@worn apex are u still there
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
sorry yeah, the subprocess module, i think i mentioned that earlier
you can use os.system too, but subprocesss is better
os.system is fine unless you need to use the output
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 olivefork()andexec()are syscalls
right, run is part of subprocess though
@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
the normal way to do this is the subprocess module
do they tell you you have to use fork and exec?
yeah they gave us a vauge idea
why don't you google how to do what you want to do with the modules you're allowed to use?
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
im sure if you looked at the subprocess docs it would become clear
okay
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
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?
I would recommend to place it into /usr/lib instead of /lib.
oh thank u so much
so the libc file shud be placed as libc.so.6 or libc-2.31.so.6?
It depends on your needs. You can just create a symlink if you need.
wait why are you putting libc in /usr/lib
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
libc goes in lib
Oh, my bad.
as libc.so.6 or libc-2.31.so?
I think just libc.so.6 should work, but dont quote me on that
sure thanks , another thing , file shud go in lib/x86_64-linux-gnu right?
yeah
thank u very much
the same goes with the interpreter too?
/lib64/ld-linux-x86-64.so.2 lib64?
I think so
I would recommend to place it into
/usr/libinstead of/lib.
I only gave you a "general" advise IMHO. I don't know what was your case. But Fedora placedlibc.so.6in/usr/lib64. So, I think it depends on what your distro.
Im using ubuntu
Yeah, sure.
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?
can it be done without creating a symlink?
@tender plinth if you have control over executing python itself, you can point it to a differentLD_LIBRARY_PATH
$ LD_LIBRARY_PATH="/home/xx/libs" python3 script.py
aaaaaaaaaaaa
Why is there a unix channel but not win? Finding help for unix is easy, for win impossible

Maybe, but I also use my computer for other stuff then coding
also, it was just a channel suggestion
Go to #community-meta and send your suggestions ๐
how do i get the time in next week using time.ctime()
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
no for eg time right and day right n0w I wanna get the same time but day next week
(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)
yeah I got it thanks one more question
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?
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
you can try asking #community-meta and discuss about it
how???
Win feels freaking ded , when it comes to developing stuff, it's hella annoying
but anyway, I'll ask
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 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
what advantages does bash have over powershell or cmd?
and what advantages does linux have over windows (except that linux is free)?
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

๐คฏ
@hollow valley he uses mac @bleak mantle
Hello?
Okay. Ping me when you need me. (Hopefully I'll be able to help)
sorry I saw this late
I managed to fix it! Thank you tho, appreciate the replies 
@bleak mantle @main olive ๐
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
try python3 --version
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?
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?
whats the error message?
with each file it says "Could not resolve 'link here'"
ex: could not resolve 'httpredir.debian.org'
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
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.
How do i sort this list of list with current day and time
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
@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
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?
Try pip install --user praw in stead of sudo
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'
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 ?
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
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
It's for a reddit bot. I'm "developing" it I suppose.
Can I upgrade from minimal to full at any time using sudo apt-get install python3?
Yeah, or better to think of virtual machines as a disposable resource, rebuild it on demand with the packages it needs
I see
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
This might be a silly question but do I need to keep the VM running for crontab to run it's scheduled commands?
Yup, assuming it's the vm's cron
ok. Thanks for helping me.
You're welcome
@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?
@ashen rover as far as I know, using the pyrhon3 command will work OK whether you install python3 or python3-minimal
python3-minimal installs the python executable into /usr/bin/python3
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 ๐
https://packages.debian.org/buster/armel/python3-minimal/filelist
just needed to look up the debian package registry haha
How do i sort this list of list with current day and time
@main olive https://docs.python.org/3/howto/sorting.html
sorted_list = sorted(your_list, key=lambda index: index[2])
I think.
@ashen rover try pip3, pip doesnt work on linux
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
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
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
Maybe just watch it on the laptop with hdmi to the TV
anyone know how I can get oracle or somthing similar to access web with my Ubuntu root?
@ me if response
nah
not possible?
heh; uhhhh no...
uh mailspring is in the aur why does it say target not found?
oh wait nvm its -S to install
my bad
exhibit a why apt is better
yay
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
I prefer yay over apt as well ๐
@austere jolt you can search for packages before installing like this
yay package_name
?
oh
i was using -R, forgot that was for uninstall, i wanted to install it
used -S next
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
@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
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
You should read the man page https://linux.die.net/man/1/gzip
Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz, while ...
@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
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.
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
- 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
- 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
Hey I'm trying to use Zeppelin from Amazon AWS but the port forwarding stucks here...no error just stuck
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?
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
I tried to look it up on internet but did not find any useful article on how to redirect file into a program
@main olive are u still there
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
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
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
it depends
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
!accept
It wasn't a general question, it was at the person above me
@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?
Can someone help me figure out how to add my Windows Download folder to my Linux Home directory?
@pearl owl sent you a dm with some tips
@pearl owl wsl?
symlink it
ln -s /mnt/c/users/username/Download ~/Download should work
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
seperate user
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?
thanks!
how do i add it as root? I put \wsl$\root@distro\ and it complains about perms
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.
@main olive yeah ๐ฆ But I want to play games ๐
wine ๐
how well it works?
idk
but it allows you to execute windows apps in linux
except
UWP apps
and league of legends
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
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?
dd\
guys what is the role of a virtual box ?????
when in shifting operating system
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
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.
๐ฆ
I know right? How on earth am I supposed to exit the editor when :q doesn't work?
nano is just too hard.
x doubt
@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
hi levemir
@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.
@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
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
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
what is unix?
it's like mac
omg and it's using zsh now too
mac, linux, bsd are all unixes
its kinda hard to define
"I know it when I see it"
@opaque ginkgo any experience with symlinks after unix updates >.>
brew upgrade didnt help
getting a ```Reason: image not found
Referenced from: /Users/asdasdasai/PycharmProjects/ExpFlask/venv/bin/python
Reason: image not found```
oh its a mac specific issue
i think it's abrew thing
because it upgraded to python 3.9
but it's looking for a 3.7 image
@blissful sage brew install python@3.7
im in the middle of a project and everything
Or install pyenv and stop using system pythons
Pyenv, not pipenv
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
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
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
uhhh i think can just recreate
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
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?
it's more likely processing
Hi
hi
hi
ls /etc/fstab and blkid to work out correct disk uuid
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
Did you mean to do python_path=$(which python3) ?
Currently you're never setting the python_path shell variable.
I set it like python_path= which python3 and if I echo python_path it ouputs /usr/bin/python3
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?
WHAT DO WE DO HERE
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
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
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
@main olive how about using .env files? python-dotenv package. Is that what you want?
@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
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.
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.
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
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