#unix
1 messages · Page 46 of 1
Hello,
Does someone know how to really
cleana terminal? Not using thecleancommand which only put previous results out of the screen, but deleting them from the terminal. It's tedious when debugging with programs with long output not be sure you're looking at the latest attempt. I've seenresetbut id does nothing for me (mac OS)
@frank coral how doestput clearwork in macos?
tput is in ncurses-utils if it isn't installed by default
tput clear has the same effect as clear for me
ah ok
Heyo, i'm having issues getting pyenv on my vps
i have 1 account that has pyenv
then i tried installing it on a new user, and when i did exactly the same it just says "pyenv not found, did you mean: bla bla bla"
so like it is installed on root
it is installed on 1 acocunt
but on the other one it just will not install
i'm on ubuntu btw
i just created the user too, so it's a clean install
@warped badge list the commands you used to install pyenv
it already works now i do believe
i just deleted the user and restarted and now it works
Hi, I'm trying to execute a Python program using the IPython interpreter.
Most recently I ran the program here and got a lengthy output: https://hatebin.com/yyhkmhrkqz
I can't understand it.
Hi, I'm trying to execute a Python program using the IPython interpreter.
Most recently I ran the program here and got a lengthy output: https://hatebin.com/yyhkmhrkqz
I can't understand it.
@olive jungle sounds like you need to installpyqt5(or another Qt lib)
what OS/distro are you on?
@hollow venture Kali Linux
how do i install pyqt5 (or whatever lib works best here)?
You know how to install packages on kali?
If so, just install pyqt5
maybe apt install pyqt5 ? I haven't used it in ages, so not sure.
@olive jungle what do you get when you run this?
python3 -c 'import PyQt5'
@summer trail nothing
then PyQt5 is installed, and you're able to import it successfully.
how do i do that?
@summer trail hey can you peek at #data-science-and-ml and see what we've been trying? we are not doing well.
Hi, I'm trying to execute a Python program using the IPython interpreter.
Most recently I ran the program here and got a lengthy output: https://hatebin.com/yyhkmhrkqz
I can't understand it.
@olive jungle is this code being run in a vps ?
Or ssh ? Seems to be xdispay not set ( no gui)
@crimson compass WSL
but i'm remoted in
so i have a desktop enviroment gui and so on
using rdp
using the xrdp service
Yes that's the issue there :)
If you run you script from a terminal within the rdp it should work
it does not work that way
i would only test a visualization tool within the rdp environment and nowhere else
Oh My! Then you have bigger issues :p
Didnt use WSL but I'm trying to understand
I'm sure its X related error
@crimson compass you can check what has been tried by looking at #data-science-and-ml we've been struggling there for a few hours
Okey 1 sec
ty
@olive jungle check #data-science-and-ml
Did you launch venv as a module ? Of python
python3 -m venv -p python3 .
@crimson compass I followed the instructions and documented all i did
i can perform whatever commands you need
i'm not sure honestly
sorry
Ok to initiate the venv correctly we should call it from within pythob
Try these
python3 -m virtualenv -p python3 .
Or
python3 -m venv -p python3 .
sudo apt install python-virtualenv
/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17
❯ sudo apt install python-virtualenv
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python-virtualenv is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'python-virtualenv' has no installation candidate
@crimson compass u get that?
unable to be located
wait nvm i located it
done @crimson compass
sudo apt install python3-virtualenv
Can you share a screenshot
source bin/activate
done
not pip install ipython3?
didn't work
What was the error
A screenshot would help troubleshoot
this should help a lot
Line 18 syntax error
Line 11 is weird
You should run it with ipython
Not ipython3
i did both for your information
Yep I've seen it
Abd the weird thing is it is still accessing /usr/lib/packages :/
Try this
deactivate
/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17
❯ python3 -m venv --no-site-packages .
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear] [--upgrade] [--without-pip]
[--prompt PROMPT]
ENV_DIR [ENV_DIR ...]
venv: error: unrecognized arguments: --no-site-packages
/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17
❯
❯ virtualenv
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--app-data APP_DATA] [--clear-app-data] [--discovery {builtin}] [-p py] [--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed]
[--activators comma_sep_list] [--clear] [--system-site-packages] [--symlinks | --copies] [--download | --no-download] [--extra-search-dir d [d ...]] [--distro version] [--distlib version] [--msgpack version]
[--lockfile version] [--setuptools version] [--pytoml version] [--retrying version] [--requests version] [--pkg_resources version] [--pep517 version] [--chardet version] [--webencodings version] [--idna version]
[--CacheControl version] [--ipaddr version] [--certifi version] [--urllib3 version] [--wheel version] [--appdirs version] [--packaging version] [--html5lib version] [--six version] [--pip version] [--colorama version]
[--progress version] [--pyparsing version] [--contextlib2 version] [--no-distro] [--no-distlib] [--no-msgpack] [--no-lockfile] [--no-setuptools] [--no-pytoml] [--no-retrying] [--no-requests] [--no-pkg_resources]
[--no-pep517] [--no-chardet] [--no-webencodings] [--no-idna] [--no-CacheControl] [--no-ipaddr] [--no-certifi] [--no-urllib3] [--no-wheel] [--no-appdirs] [--no-packaging] [--no-html5lib] [--no-six] [--no-pip]
[--no-colorama] [--no-progress] [--no-pyparsing] [--no-contextlib2] [--symlink-app-data] [--prompt prompt] [-h]
dest
virtualenv: error: the following arguments are required: dest
/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17
❯
Great
it says something else is required 😦
Yeh one second
unset PYTHONPATH
python3 -m venv .
And then
source bin/activate
is this a command? unset PYTHONPATH sorry i can't tell
Yep
done
Know we will check if your venv is isolated
Run these two commands
whereis ipython
And then just run
ipython
And let me know of the output
Good
it seems odd that there's ipython located in the paul deitel folder
Can you run your script now
Yes that's the venv we've created
Yes for the venv you can delete it and create it elsewhere
Do you have a requirements.txt in that folder ?
no
( otherwise we will get dependencies one by one )
Hhhh ok let's go than
pip install matplotlib
It would be easier if you share the import section w
Of the script
We will guess the required packages
i'm just a beginner but beginning is hard
And then you can put them in a txt file and name it requirements.txt
i'm just a beginner but beginning is hard
@olive jungle nah you're fine , keep going
( phone keyboard is laggy )
Always keep in mind to store the required packages in a single txt file
first command complete
And then you can just run
pip install -r file.txt
Will get all dependencies mentioned in the file ;)
ty
Ok rerun your script
sure also i just wanna remind u i intend to use ipython for like 16 lessons lol
do i have to do this x16?
cause that would suck
Nope
ok good
Create a new txt file in that folder using nano for instance
And put these in it
it hasn't finished installing seaborn
Ok just wait for it till it finishes
These are the required packages from those chapters
Found it on github
pip install -r the_file_you_created.txt
( go grab a cup of coffe coz it will be long )
That should be dnspython
Not python
Check the first line of the requirements file
ok here we go
it's in progress
Yeh that's why I told to grab a cup of coffe
Coz silckit-learn as a package is way too heavy :')
Now last thing which I'm not sure about is that the script is trying to plot graphs
Dunno if WSL will pipe that into your graphical interface or will it crash 
Its 3 am here
Will be around for 15 minutes, hope you get that requirements installed by that time
And good choice to learn python 👋 👍
https://hatebin.com/clrrdqbmlj @crimson compass
i started getting a lot of errors
but it's still running
i copied the 100% of the errors but not the entire output
(also thank you very much for your assistance)
after the requirements.txt install is complete or in a separte terminal?
In a separate one please
ok
did you guys figure it out?
oh geez looks like no
im still confused as to why apt install python3-* didnt seem to actually be installing python 3 packages
@crimson compass /mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17 Py ch01
❯ ipython RollDieDynamic.py 6000 1
/mnt/d/Section 9/Paul Deitel/ch01/RollDieDynamic.py:43: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show() # display window
/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17 21s Py ch01
❯
@crimson compass /mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17 Py ch01
❯ ipython RollDieDynamic.py 6000 1
/mnt/d/Section 9/Paul Deitel/ch01/RollDieDynamic.py:43: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show() # display window/mnt/d/Section 9/Paul Deitel/ch01 master !1278 ?17 21s Py ch01
❯
@olive jungle this problem can be solved by writing your statements in a jupyter notebook
I'm only interacting with the person I pinged
and no, it cant @molten wedge , this is part of an unrelated issue
oh okay, was just trying to help
@crimson compass i'm back. posted screen of problem.
Now last thing which I'm not sure about is that the script is trying to plot graphs
@crimson compass @olive jungle as I told you yesterday this will through an X display error while plotting
Otherwise the packages are ok
centos 7: how do I change the 'll' alias. I can't find it in bashrc or anywhere
got it /etc/profile.d/colorls.sh
hey @dull nymph it's been a while but i believe it's
~/.tcshrc
when scp something you need to
- use the command from the source user
- if the source user is a remote server, you do not need to provide the
root@ip_address
when
scpsomething you need to
is that a question, or an answer to a question?
it was a question but i figured it out
username doesn't check out?
This is not directly python related
On unix, where would you expect a script to appear when you install something?
home/user/bin or maybe in the install location, but export PATH="$PATH:$HOME/install/location/here" is appended to .profile ?
I am new to unix so I don't know what the standard is. I want to automatically add a script to PATH.
Depends on the installation method.
Manual installation, /usr/local/bin/ is a good choice.
If it is packaged, /usr/bin or just /bin is good
and those will be on path already or should I add those
/usr/bin and /bin should definitely be. /usr/local/bin should also be.
It is by default on arch, at least. (I use Arch, btw).
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Also on Ubuntu

Off-topic channels
There are three off-topic channels:
• #ot0-psvm’s-eternal-disapproval
• #ot1-perplexing-regexing
• #ot2-never-nester’s-nightmare
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
@toxic solar
yea that's nice but this channel is dedicated for a specific topic
the off topic channels were made for random purposes like these
I won't stop you if you want to continue doing it here
but just an idea
Hello , I've been trying to count the number of times a bash script is invoked , but storing count in a file and reading from it , can sometimes cause race conditions , so I dont prefer that method , another thing I came across is the flock which kind of holds a lock on file when an IO is happening on it , but Im not able to implement it properly , can someone give me an insight on this?
#!/bin/bash
file="/tmp/count.cnt"
flock -xn 200
trap 'rm /tmp/count.cnt' 0
RETVAL=$?
echo "acquiring lock"
if [ $RETVAL -eq 1 ]; then
count=$(cat ${file})
if [$count -eq 0]; then
echo "Building now"
docker build -t container . 1>/dev/null
docker run -dit --privileged container 1>/dev/null
nc localhost 1234
else
nc localhost 1234
fi
else
echo "Sleeping"
echo 0 > /tmp/count.cnt
fi
200>/tmp/count.cnt```
@tender plinth to lock the file in the current script's context, i've simply used
exec 4<>/my/file/here
flock -n 4
ah thanks @main olive
u dont check if the lock has been acquired successfully or not?
Hi. I am trying to understand what login means in linux.$ w USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT ennozdd :0 :0 10:47 ?xdm? 8:27 0.00s /usr/lib/gdm3/g
ctrl+alt+f3 to see how another console will show up$ w ennozdd :0 ennozdd tty4 - 20:08 13.00s 0.08s 0.05s -bashI also ran multiple instances of gnome terminal to see if each one counts as login but no it didn't make any difference in the output.
on tmux however there are multiple logins```ennozdd pts/2 tmux(11089).%0 20:11 3.00s 0.04s 0.01s tmux
ennozdd pts/3 tmux(11089).%1 20:11 2.00s 0.04s 0.04s -bash
ennozdd pts/4 tmux(11089).%2 20:11 2.00s 0.04s 0.04s -bash
ennozdd pts/5 tmux(11089).%3 20:11 2.00s 0.04s 0.04s -bash
ennozdd pts/6 tmux(11089).%4 20:11 2.00s 0.04s 0.00s w
@humble onyx gnome terminal doesn't use a login shell because you are already logged in when you are opening the terminal
you can start a login shell manually of course
1 - why did tmux make such a difference or why were my terminals not listed?
2 - Does :0 mean there is a GUI login?
3 - $ps aux gdm 1448 0.0 0.0 299432 7156 tty1 ennozdd 10577 0.0 0.5 698416 43256 tty2 Sl+ 20:04 0:00 /usr/share/discord/Discord there is also tty1 and tty2 I see
tmux specifically uses a login shell because tmux windows typically persist after the original login session ended
the idea is that you log in once per tty. tmux is a bit different because your tmux session is meant to be independent of whatever your current session is
https://unix.stackexchange.com/a/336527 :0 is an X11 thing. tty is the linux console. ptty is SSH, gnome terminal, tmux, etc.
Hello , Im planning to use nsjail over docker for one of my services which I intended to host over a server, but Im not really sure how we can use nsjail over docker, can someone give me an insight into this?
thank you @formal schooner
arch is a skid version of gentoo, change my mind
Is killing you allowed? @prime atlas
jk though
never used gentoo but I am an arch fan
lol yeah that was my point haha
you arent building everything from source with arch
gentoo is wayyy more DIY
not even comparable
do people even use it?
I've seen people say i use arch btw (i use Arch btw) but never for gentoo
gentoo is still used but it has always been a niche community
see also: slackware
really nice for headless
In my .bashrc file, how would I access this environment variable?
PAL:DriveLetter=V
The usual $VARIABLE_NAME isn't working. It thinks that everything after the : is a command.
${varname} @tawdry sonnet
That's a step in the right direction, now it just prints a blank line like the variable doesn't exist.
i didnt know you could even have an environment variable with a colon in it
: is special syntax for parameter expansion in bash
so that wont work either
https://stackoverflow.com/a/2821183/2954547 interesting
it might not actually be possible in bash
@tawdry sonnet maybe use python: python -c 'import os; print(os.getenv("PAL:DriveLetter"), end="")'
the end="" doesn't really help; if you're using that from a shell script command substitution will strip off a trailing newline so that the end result is the same with or without end=""
I think you're right that there's no way to do it with bash, though. That's interesting.
Good point
I'm using GitBash for Windows via the PortableApps launcher. The launcher passes these variables when launching GitBash, so I wanted to use a few for some custom functions and aliases.
I ended up writing a wrapper in python that will create the variables I need before launching GitBash. Works 👍
guys why does sudo cd directory/ give me a command not found error? I'm pretty sure I have cd lol
Because it may not be on the PATH for the root user
Hmm wait
Is cd even a binary
Or is it like a shell built in?
Yeah I think it's a built in
Is NS2 run on kali linux?
ns2?
@loud sky continue discussing here
seems like python 3 is installed
when I typed python3 I get:
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
then try pip3 install -r requirements.txt
it is loading
cool but you'll also have to change the default python from python2 to python3
The bash line - is blinking
ok
pls wait a some time
Its still loading
ERROR: Could not find a version that satisfies the requirement magic (from -r requirements.txt (line 4)) (from versions: none)
ERROR: No matching distribution found for magic (from -r requirements.txt (line 4))
The same error
ehhh
argparse was installed
what linux mint version are you on?
20 cinnamon
argparse was installed
@loud sky argparse is a pre-installed python3 module
oh
I don't really know how to help you further
if you want, then you can open a help channel
you might not get a solution the first time, so don't worry about that, and open a new one as soon as you can (30 min)
you might not get a solution the first time, so don't worry about that, and open a new one as soon as you can (30 min)
@molten wedge How to set default python as python 3?
I was looking that up
looks like linux mint > 19 should have it set as default
but yours doesn't
that sounds like a bad idea, it's there for a reason
Should I remove old python
@loud sky
oh
Hey! anyone knowledgable when it comes to setting up python on mac? i cant seem to get my terminal right
How to make app like vitetris using python i.e. some gui on terminal
I’m officially fucked
What’s up?
arent we all
What phone?
iPhone
Maybe you can factory reset it.
jesus christ no
More importantly, what the fuck kind of file was it, and what kind of garbage phone breaks if you put a file on it? lol
i just gotta figure out how to delete the directory i made
it’s a .deb
and a bunch of .plist files
They get copied to the rootfs even after restoring it..
how can i run a python script in background? also i have a virtual env for it
First u need to make sure the file dosent exit
The thing is, i need root access in a terminal to delete the directory
Its sandboxed :/
a little more details please, i am not that advanced, also i am using ubuntu
yes
it's already that kind of app, it's a discord bot
we need to setup a service on linux to run that file
oh cool
i have a discord bot on a virtual machine provided by digital ocean
i use systemctl service to run it
ok
i can share my service file
but first
i want to you to know it is and how to set it up
look at this article
read from turning it into a service
basically, u need to make a service file that the operating system can understand and perform the task listed in the file
Who pinged me?
[Unit]
Description=YNB discord bot
After=network.target
[Service]
Type=simple
Environment="PYTHONPATH=/home/rohan/.local/lib/python3.8/site-packages"
user=rohan
WorkingDirectory=/home/rohan/YNB-DiscordBot
ExecStart=/bin/sh -c 'python3.8 -m ynb-bot'
[Install]
WantedBy=multi-user.target
this is my system service file i use to run my discord bot
@hollow venture did you ping me?
ok, thanks a lot
i pinged by accident before when i mentioned sudo. is that wht ur refering to?
The terminal i am using doesn’t recognise sudo therefore i can’t get root access
are you using pipenv or env @atomic ember ?
env
okay, for the Environment variable, u want to set it to the env
in my case, i had installed the required packages gloablly so i refrenced the global python installation
and how i can set the env?
@blazing wolf if you have any other ideas pls let me know
what kind of OS is that
iOS
it has a variable
Environment
@blazing wolf i got it, thanks
what happens when u just type su
It doesn’t recognise it
This is a sandboxed app though
Fixed my phone :))))
cool, how did u do it @lavish hemlock ?
I sideloaded an IPA to my phone, used a different exploit to reinstall openssh and reset the root password, and deleted the directory
@blazing wolf
nice
hello mates I'm a newbie here
@vestal leaf hello howdy we all newbies in something :)
ahaha thanx Zrouga, I'm appreciated to part of a community like this.
learnt about flock (http://manpages.ubuntu.com/manpages/xenial/man1/flock.1.html) last night. absolute life saver
how to open arch cli in ubuntu cli?
arch cli is just bash terminal. what you can do in arch cli is the same as what you can do on ubuntu cli
https://hub.docker.com/_/archlinux/ Arch does have a docker image
Arch Linux is a simple, lightweight Linux distribution aimed for flexibility.
i want open arch architecture cli on ubuntu
Not quite sure what you mean
The CLI/Terminal that you have on Arch is about the same as you'd have in Ubuntu, the main difference between them would be the package manager/packages if anything
@hollow canyon you've got a bunch of options here.
First of all terminal emulator (or terminal for short) is the program you open that houses the shell (defaults to Bourne Again SHell or BASH for short).
There are a lot of options for terminal emulators (Termite, Terminator etc) and also for shell (bash, zsh etc). You need to specify which of the two you want to change, -probably the shell- but the default one should be BASH in both ubuntu and arch.
Only way to get a different shell during an arch installation is to use an arch based OS like ArchCraft which uses zsh as the default shell.
Please provide more information so we can help you further
Arch uses zsh during installation too, but it disappears as soon as installation is complete
weirdest shit I've seen
it's weird because you don't understand it, the live ISO uses zsh + grml-zsh-config (https://grml.org/zsh/) as the features result in ease of use during installation (completion etc..)
the reason it disappears as soon as installation is complete is because the packages on the live media is separate from the packages you end up on your system
when installing arch, a step is to install the base package (https://wiki.archlinux.org/index.php/Installation_guide#Installation), which among other essential stuff installs bash, which is mandatory and an obvious choice for a default shell
it's up to you to install another shell and use that
yeah ik that.
but during configuring the archiso, what parts of the packages.x64_blahblah dissappear and which one remains?
configuring the archiso
I assume you mean during installation,
after a standard installation using the guide (assuming no other packages are installed other than the explicit requirements), the only packages that are installed are linux, linux-firmware and the base package, the contents of which you can see here-> https://www.archlinux.org/packages/core/any/base/
I assume you mean during installation,
No no you assume wrong
i mean the archiso which is used to build the actual iso
@robust cave
@molten wedge packages.x64 is all the packages in the live CD (aka Arch ISO) https://gitlab.archlinux.org/archlinux/archiso/-/blob/master/configs/releng/packages.x86_64
I'm not sure what you mean by actual ISO
so if i add Firefox in this list and install this newly built ISO on my computer, will I get Firefox in my new computer or not? @robust cave
the Arch ISO is not what ends up on your computer, it's just the tool to help you get everything you need for a functioning arch installation
Is there a way that I build an iso so that Firefox is already there on my pc when I finish installation? @robust cave
I'm not sure what you're talking about? you just have to install firefox (like pacman -S firefox in arch) during the installation process, and it'll be there when you finish installation
But suppose I have a large list of packages that I already need installed and I don't want to remember all those names.
for eg if you install Ubuntu on your system, you will find that dolphin file explorer is pre-installed
hm, you could always keep the list of packages somewhere, then after a minimal installation install them all at once
if you do that frequently though, maybe look into something like NixOS
I'm not familiar with it though
yeah that could be done
hm, you could always keep the list of packages somewhere, then after a minimal installation install them all at once
@robust cave
2012.sqlite3
2012.sql
2012.xml
how do I rename these files to be
2013.sqlite3
2013.sql
etc
i think python script would be easier than using rename
yeah... fucking bash
um... that's a weird flex
Idk I used to like bash but since I learned python it feels so...
@dull nymph bit late on this one, but
NUM=2012
for filename in ${NUM}.*; do
mv "${filename}" "$((NUM + 1)).${filename#*.}"
done
think a python script would be overkill here
yeah... fucking bash
@dull nymph if you can overlook the slightly unfamiliar syntax (but still nothing compared to other, more esoteric languages) then bash is very powerful
Hello , I've been trying to debug binaries enabled with Intel's Control-Flow Enforcement protection , is there a way to enable CET while compiling a binary with gcc?
Thanks @main olive that's a nice one
Probably a good idea to use mv -i so it doesn't overwrite existing files @dull nymph
Where is that -v at though
Optional 😄 I tend to use it, but it won't cause data loss if not present.
basically, I have a remote server running a discord bot, which I can connect to. the way I'm currently updating my code is using some file transfer tools every time I want to update my python code, then ssh-ing in to run the code again. Is there a way to push code from my computer to the server with git, and also force python to restart using the new code, so it doesnt take 5 minutes to update my code?
i know git supposedly can be used to push code there, but I also need the code to restart
the code is running in a screen so it stays even after I close my ssh client
You use GitHub @solar glade?
basically, I have a remote server running a discord bot, which I can connect to. the way I'm currently updating my code is using some file transfer tools every time I want to update my python code, then ssh-ing in to run the code again. Is there a way to push code from my computer to the server with git, and also force python to restart using the new code, so it doesnt take 5 minutes to update my code?
@solar glade a "deploy webhook" might be worth looking into
I think you can set up Github actions with a Github runner on your server.
I do that with GitLab, at least.
How exactly do i suppress the output of this command ?
[ $(grep -oE 'gcc version ([0-9]+)' /proc/version | awk '{print $3}') -gt 5 ] && \
echo "WSL2" || echo "WSL1"
when i run it, the output is ```
+WSLverdetect.sh:4> grep -oE 'gcc version ([0-9]+)' /proc/version
+WSLverdetect.sh:4> awk '{print $3}'
+WSLverdetect.sh:4> [ 5 -gt 5 ']'
+WSLverdetect.sh:5> echo WSL1
WSL1
how are you running this?
try with bash
same
do you have some debugging option enabled
nope
try a different shell script
i tried adding /dev/null after [ $(grep -oE 'gcc version ([0-9]+)' /proc/version | awk '{print $3}') -gt 5 ] but that did nothing
i also did zsh WSL.sh > /dev/null 2&>1 but hides everything lol
why ?
testing something
i think that's obvious to happen when executing some command i guess ?
does anyone have enough knowledge about mariadb or mysql in arch here?
Pacman -S mysql
[ + ] ufw
$ ps aux | grep ufw
#no output```Isn't a service supposed to be running in the background?
alright so uhhhh
i need a lot of help
so i've got this vps running ubuntu 20.04
and also bind9.16
it's running a website, so it provides DNS for that ig
but now i'm trying to also run a python script on it
and it keeps returning failure in name resolution
even though things like ```bash
$dig discord.com @127.0.0.1
it just doesn't work when i try to do it with Python
anyone have any idea how to fix this?
Trying to call a strange port?
.
not really, DNS should be on port 53 and I think I allowed that through firewall
hey
HELP PLEASE!
I need to get rid off special characters between chr(128) and chr(153)
How do you do that in unix
and also I am getting an Illegal byte sequence error when I am trying use the cut command on file
@wind adder are you asking about doing it on the command line, or in python?
Either way
command line would be nice
the problem is the encoding right now
it's trying to read en_UTF-8
and I think this file has characters not supported by that
I am trying to look into perl, but if you are aware of some perl, could you tell me how to do a simple regexp_replace with perl
cat file | perl s/regex/replacement/g
How about that, I have a very specific requirement to block out only certain latin coded characters
as bad as python 2 was with text encodings
python 3 is pretty good
do you know the actual encoding of the file?
I think I do let me check
ISO-8859-1
oh actually do u know if tr works with hexcodes
ah dang okay i have to use another encoding
tr -dc '[:print:]' < infile > outfile
same problem, illegal byte seq
python can read that encoding
with open("myfile.txt", encoding="iso-8859-1") as fp:
text = fp.read()
@wind adder
correctly reading the correct encoding is much better than arbitrarily deleting bytes...
hmm u know what i think this is probably a better idea
than me trying to pick up sed and awk
at this point in time
still though i dont know if i shud really go the python route
cause the end goal here is to make some kind of a wrapper on an already existing bash command
your program only accepts utf-8 encoding?
no no i dont think the encoding is a problem for the other bash scripts
i am trying to build a wrapper on another bash script thats making use of this file , i want to clean up some trouble some characters
why are they "troublesome"? you just need to read the file in the correct encoding
we are using that characters properly for oracle db, but for some reason sales force craps out
maybe salesforce requires utf-8 input?
the characters cant be processed well on some platforms
ya they might have a restriction
i recommend writing a small python script to convert the file from iso-8859-1 to utf-8
utf-8 is a better and more commonly used encoding nowadays
with open('file.txt', encoding='iso-8859-1') as fp_in:
with open('file-utf8.txt') as fp_out:
fp_out.write(fp_in.read())
that's it
okay I will try it, I have to check to see if something in the oracle db is not dependant on those file characters too
thanks.
good luck. tools that use bad old encodings are a real nuisance
Yeah agreed
I have a really weird issue with nano + tmux
so basically, when I press the down arrow when my cursor is at the start of line 1(before the a), the cursor moves to before the 2nd line's line number and typing anything messes up that line's display
but this apparently only happens with all of the following: nano with line number enabled, tmux, and windows terminal
nano w/o tmux on wt works normally
nano w/ tmux but using cmd as the terminal works too
can anyone help?
I am having problems with pip3 on elementary os running ubuntu 18.04 on it
whenever I try to install using pip3 it gives this long error
your pip installation is probably wack
you can reinstall using this https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py @dry bronze
your pip installation is probably wack
@molten wedge my life indeed
Hey guys, I'm trying to use pip on my WSL but I run into this path error. I have added the path to my .bashrc (top row is the cat of .bashrc) but it does not seem to work
Anyone have an idea?
so I added export PATH="/home.." to the .bashrc already
FYI, this is what happens when I try to apt install it
@bitter creek i think you removed the pip from your PATH since pip should be installed in /usr/bin
let me check!
tbh, there's nothing to check. Unless you really need to, you should probably remove the export line from bashrc
Found a workaround, thanks for the input
Hi,
working on a Makefile and cant seem to even make simple stuff work
@echo $$NUM
@$(a=$$((NUM + 40000)))
@echo $a ```
i just want to add 40000 to NUM and work on with that value
feels like I tried hundreds of combinations, but nothing seems to work
NUM comes from the CLI. so I run make start_cores NUM=3 and the first echo returns the correct number
So uh,i made an electron app and made an msi installer for it in windows ofc.
i packaged the app for linux too but idk how installers work in linux
lemem show a ss
since im on windows
it show the packaged app as a unknown file
an*
its a folder
for the msi,i created a zip and the msi will just self-extract it
Can you open the file as text?
Does the file start with #!?
@fresh saddle starts with
Thats a binary file not a bash file
Good catch, there’s the ELF magic number
It is a (linux) executable
You should be able to
thats great ig but i want to share that
in github
as a direct downloadl ink
link
@fresh saddle thanks btw
You are welcome
hey need some help with ubuntu grub boot loader anyone here??
@hot dragon yes
what's up?
Hi, I'm new to this linux ecosystem and I wish to repurposed my old 32bit system as a server where I can host some websites, and other web scraping scripts. I know about ssh using which I can connect to my Machine but how exactly should I run those scripts and host website. Like do we just roll it in terminal? If yes then how can I access that terminal so I can say terminal a script and run again
Perhaps have a look into crontabs, they are like shell scripts but they will run at boot or at a regular inteval
@stark tide
Suppose I have 3 scripts running. One a scraper, a website and a bot for discord. Now I wish to access my pc via ssh and terminnate the scraper for maintainance. Is this possible via ssh?
yeah you have to find the process id for the scraper and kill it @stark tide
@stark tide look into systemd units
you can use them to manage "daemons" aka background processes. Run them at boot, stop/start them, etc
stopping your scraper would be as easy as systemctl stop scraper
Thanks everyone
hey yall. I was seeing the news about zsh becoming the default shell for mac. When I use the terminal does that mean I have to type zsh every time I use it? On startup it always runs bash too. So do I just disable the bash running on startup or have it run zsh on startup? Thank you!
isn't that old news
but im pretty sure that only applies to new computers
never payed attention to that
well I mean I am running a relatively new system
mac mini
chsh if you already have bash as default I think
so just change the shell?
Alright I did end up changing the shell
However
Everything broke python wise
All packages are unrecognized and anaconda has given up
Probably has to die with path errors gonna fix it soon
Has anyone else had these problems?
Hello, can somebody help me out with starting a debugging session with pudb? I don't have much experience with Python, so I'm struggling to understand WTF is wrong. My goal is to debug calibre, at this point:
https://github.com/kovidgoyal/calibre/blob/master/src/calibre/ebooks/mobi/debug/main.py#L45
with this debugger:
https://documen.tician.de/pudb/starting.html
I installed it, I insert the breakpoint as the documentation says, I launch the script with
calibre-debug main.py -- /path/to/ebook.mobi
It says ModuleNotFoundError: No module named 'pudb'. Why is it not found if I installed it with pip?
@desert oasis haven't looked too much into the project, but it may be possible that calibre-debug uses its own virtual environment (where pudb isn't installed)
I see. Where can I see a list of modules that is inside virtual env?
Anyways, I'll go and read virtualenv docs, maybe that will help
add the following to the top of a file whcih you presume would be run inside the environment when calibre-debug is evoked:
from pip._internal import main as pipmain
pipmain(['freeze'])
this should print all of the installed modules
similarly, you can use pipmain(['install', 'pudb']) to install within the venv
(((this is under the presumption that it does indeed use its own environment)))
how did you install calibre in the first place?
Something weird happens:
from pip._internal import main as pipmain
ModuleNotFoundError: No module named 'pip'
i installed calibre using my distro's package manager and calibre-debug does not use its own environment (and has pip) https://arse.ee/YrPluEy1.png
I installed calibre using their binary installer, and not with my package manager (pacman).
I debug as documented here https://manual.calibre-ebook.com/develop.html#debugging-tips
Basically I set CALIBRE_DEVELOP_FROM to checkout path of calibre and now then it knows where to look for python code.
It works alright, but the question is how to integrate it with external debugger.
not even a venv, a full separate python instance
honestly, my suggestion? use pacman's version of calibre
So I would have to rebuild it from source with pudb included in order for it to see it?
just be sure to do sudo /usr/bin/calibre-uninstall first
pacman's calibre uses the system's python install
so pudb etc works
But does pudb work if I install it with pacman? The reason I used their binary installer in the first place was because I could not even use print debugging if I install with pacman.
Although I inserted my print statements in the checked out soure directory and hoped it would respect CALIBRE_DEVELOP_FROM variable. Maybe I should have done it in wherever pacman installed calibre.
https://arse.ee/bR55YXrX.png works on my machine
although i'm not sure if it respects that env var
I'll try that
hi guys, anyone here is using Mac OS?
I have Catalina build and there is folder called Others in my Finder - how can I access it? right now that function is greyed out
@fickle wadi uhhh
can you post errors?
idk how changing your shell would break python
oh
fix your zshrc
copy the stuff in bashrc to zshrc and bash_profile to zprofile
if you have syntax errors, google what the right syntax is for zsh
Hi Im working on unix terminal with python
im new to unix, how do you make a wrapper, I want to do some re.sub on the files that are passed as arguments to a bash cmd, and then recall the same bash cmd with the new file and same options
anyone have any experience with this
# wrapper.sh
output=$(python my_wrapper filename)
echo "$output"
# my_wrapper.py
import sys
print(sys.argv)
@wind adder Basically you have to catch the print statements in your python script and then use them in your bash commands.
Hi IgnisDa thank you for reply, I am using sys.argv but I am having trouble thinking of how to structure this thing in general
In practice you should probably be using argparse
right now I have something like this
Test.py:
import sys, re
with open(sys.argv[1],'r',encoding=...) as f:
print(re.sub(r'...','',f.read)
Now I want this to be actually called when lets say they type
Terminal: bash_cmd -iwdg s_list.txt
I will rewrite this bash_cmd
#!/bin/bash
python test.py $1 > $1
bash_cmd "this is the part im confused, how do I make sure all the args are passed in here, and I am not too sure if they will call this command on just one file too"
!code
!code-block
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```python
print('Hello world!')
```
Note:
• These are backticks, not quotes. Backticks can usually be found on the tilde key.
• You can also use py as the language instead of python
• The language must be on the first line next to the backticks with no space between them
This will result in the following:
print('Hello world!')
#!/bin/bash
output=$(python test.py)
bash_cmd "$output" arg2 --named-arg arg3 --verbose
@wind adder I have no idea what bash_cmd is, so I will leave that to you
It's not a real command I am using it as a placeholder for any bash cmd
But okay the thing is, what if they passed in multiple arguments into this bash_cmd to begin with
I want to make sure those arguments and options are still preserved
@wind adder edited previous answer
oooo Okay perfect I will try this thanks
Yeah, also make sure to quote your variables like I did so that backslashes are not mangled
ah yes
I need help installing python packages!
I'm using a Linux based system that is on a chromebook and I installed everything to run Java files which I think is JDK and Java Envrionement. Now I want to try from python. I need to import a a package using "import turtle" but I'm not sure how to actually do that?
I think I'm suppose to download the linux version on anaconda but I'm not sure if that's the right way or even how to install/run it in my chromebook based linux.
Thanks!
turtle is part of the standard library.
Which distro are you using @sick granite not all of them include it by default
ah, a chromebook
Also, is the this appropriate discussion to put this question in?
I figures unix and linux was similar? I'm not sure.
If you've installed that you should be able to import it.
and that will give me other general files to import right?
That'll allow you to use pythons tk basked packages, turtle is one of those.
If you've got it you can put
import turtle``` at the top of your files
can I just install all python packages if I exclude "-tk"?
no
then how would I be able to install like all the general files for my python class?
Like the way Java uses JDK.
hmmmm......so I have the general importable files? just not the tk based ones?
You have the rest of the standard library already
how do I check if I have them?
You could try importing a few, but I guarantee you have them.
ok
I have another question.
I'm trying to build a computer and I want to make it linux based. Would you recommend a Ubuntu enviornment? Like GNOME or something?
Ubuntu is a fine choice.
whats the diff between that and GNOME?
Ubuntu is a distribution (distro), GNOME is a Desktop environment.
They are fundamentally different things
so Ubuntu is like my OS and Gnome is just how the desktop will look after processing Ubuntu?
yeah the top layer of what you see is gnome
the kernel and all services are those of ubuntu
has anyone played with GRUB before ? I'm thinking of making a GRUB2 theme
can the menu items be resized to a rectangle or square shape?
here you go
guys i need to convert a .exe file to a .msi using python
anyone knows some possible solutions or packages that i can use for this?
you can package an executable in the .msi file but converting the actual code is probably impossible
Hey, I was wondering: are environment variables just a feature of the shell, or a feature of processes?
I.e. does a process not launched from a shell have environment variables?
Where are they stored?
Ah right, so they are part of the process control block?
Ok, turns out they are stored in the process's memory.
How can I come up with a grep that gets me all objects that have the string MyServer1.1.* - the idea is to get the whole json from { "ip"............MyServer..... to end of json object }, https://dpaste.org/yFVR
Hmm, you want to parse json with grep?
It might be difficult because json isn't a regular language.
but i think is possible because the different flags grep has tho
i just need to identify the init char, a middle reference and the end. Copy everything between
like some kind of regex for grep
but use jq or something
Do you have to use built-in unix tools?
^
not really
i checked groun seems like can do the job
but why you say to use jq
well seems like gron cant find some of the objects in the file :/
@opaque ginkgo gron dont find some objects because of unicode
grep can't parse json
use jq
can you guys gimme some help with jq
maybe jq can do it and i dont have to code anything like it, but if jq cant do the job that's what i need to do
Actually, perhaps you could write a small python script to do this?
Python has json parsing in the standard library.
This is the python discord, just saying 😄
And python is available on most unix installations today.
ye but im parsing stuff thats coming from another software and i dont want to code something just to use more ram
however, my json file contains some unicode as you guys can see on the paste
and even with jq, i dont get the data im interesting in due
parse error: Expected value before ',' at line 1, column 125
and i dont have control of the json data
how it is generated
Ah right, so it's not necessarily valid json.
but it seems to generate a valid xml, what similar tools i got for xml?
Maybe xpath?
im trying it out, can u help out with the syntax please? first time using it
it should get the object starting from <host..> but only those with the string MyServerV1.1. in the middle
xpath -q -e '//host' goxml.xml
gives me the element i want but i still need to filter the results by MyServerV
any feedback guys?
Hello , I've been trying to print names of caller functions inside a segfault handler , and with builtin_return_Address function , I dont seem to get meaninful results. I've also tried using a foreign library called libbacktrace but it segfaults even before calling it's internal print statements (which are async-unsafe) , moreover I also tried changing all printfs to write , that also to no use. Does anyone have a better way to printing caller function names from inside a signal handler?
if browser == "firefox":
self._options = F_options()
if binary_location is not None:
self._options.binary_location = binary_location
if headless:
self._options.add_argument("--headless")
if options is not None:
for option in options:
self._options.add_argument(option)
self.driver: FireFoxDriver = webdriver.Firefox(
executable_path=executable_path,
options=self._options, # Some how this line is causing error
)```
File "rex.py", line 37, in <module>
options=ARGS,
File "/home/avinash/CodingStuff/Projects/Rex/RexWrapper.py", line 57, in __init__
options=self._options,
File "/home/avinash/.local/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
File "/home/avinash/.local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.7/subprocess.py", line 1436, in _execute_child
executable = os.fsencode(executable)
File "/usr/lib/python3.7/os.py", line 809, in fsencode
filename = fspath(filename) # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType```
works fine on my windows, throws this error on my Linux Machine
is there a way to cd back by two directories
cd ../../
O
@stark tide 2 things: you need to do export GECKODRIVER_PATH=...
the reason why PATH doesn't have it is because its already exported by something earlier
secondly, move that line to the very bottom of profile
not within any if statemnts
@opaque ginkgo yeah, I just got done with it
Btw, how can I keep a process running even after I quit terminal? I'm accessing my linux box setup on local network on windows and want to use it to run stuff 24/7 for scrapers, websites and bots
I tried running a python bot and it stopped once I quit terminal on my windows
Btw, how can I keep a process running even after I quit terminal? I'm accessing my linux box setup on local network on windows and want to use it to run stuff 24/7 for scrapers, websites and bots
@stark tide yousshinto the linux box? You can usetmuxfor that.
tmux new -s mybot to start a new session called mybot
Run the command, then ctrl+b, D to detach from the session
tmux ls to list sessions, tmux a -t mybot to reattach
Thanks @hollow venture
There are other options, of course. You can dockerize apps, and run those as daemons.
But tmux is the most hassle free.
hi i need help
i got this error
File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: ' lsblk | grep disk | wc -l'
when i run this subproocess command
total = subprocess.check_output(' lsblk | grep disk | wc -l', stdout=subprocess.PIPE).stdout
your code throws a different error when i tried it
(the other way would be to use three Popen objects, with stdout connected to stdin of the next command)
either use explicit stdout= or check_output, not both
it should be subprocess.run in this case
I'm working on packaging Ren'Py as a flatpak which succeeds in building and can run some example games, however there are some issues at runtime that I'm trying to tackle. One big issue is that it requires tkinter which seems to be shipped inside the flatpak build, but it can't seem to find that package (looks like tkinter has been moved to /lib/python3.8/site-packages/future/moves/tkinter inside the build) so a lot of GUI functionality isn't accessible. Does anyone know how this can be fixed? Here's what the build manifest looks like: https://gist.github.com/joshua-stone/398854037400b05ce43884e8145ffd2f
Its not advised to install kali because its goto user is root. But it is possible. If its the tools you want, you can just install them separately. Most of them dont see much use anyway.
okayy
anyone know of any good wpa_supplicant libraries, preferably over dbus?
kali doesn't default to root anymore
@dreamy wing
it's now kali:kali
but yeah don't use kali if you're a beginner
if you're asking that question, you shouldn't be installing kali
Hi guys need help with my Amazon EMR...trying to access python file using EMR
The python file I'm trying to execute it "pi.py"
your scp syntax is wrong
scp /path/to/local user@remote:/path/to/remote
@hard bear
Thank you
does
unix == linux?
no
@wary crane you don't need kali to learn hacking
i've been doing ctfs with a vanilla wsl debian install
@solemn snow unix nowadays refers to many different os's that are similar to the original unix, which was an os developed in the 70s
linux is a os that is classified as a unix
but its not the same
for instance bsd variants are unix but not linux
oh so can we ask windows related questions here?
Okkay @opaque ginkgo thanks for info
Last night I tried to dual boot Linux onto my computer, but apparently I had to shrink the main partition to create space for the new one. And it wanted me to defragment before shrinking the main partition. Which I guess makes sense so that you can have contiguous space for the new partition. But it never got above 0% defragmented even though I just reset this computer so why would there be so much to defragment?
@analog jasper my computer is primarily windows and I was going to add a Mint partition
Namely windows 10
@analog jasper my computer is primarily windows and I was going to add a Mint partition
@granite aspen were you running the defrag in Windows? Maybe trygparted.... https://gparted.org/livecd.php
isn't that for partitioning if you're currently running linux?
Nah you can run gparted on a live stick
Yup. The link I shared was for the live CD/USB.
The advantage is that you can operate on an unmounted FS, so you know files are not in use.
(Note that I haven't had to deal with a Windows partition since Win 7, so not sure how well it works with win 10).
I did erase everything and install linux 😛
But yeah the gparted should work, what I used to do before was create a partition in windows using that disk partitioning GUI and then during the live install selected that partition as main one and default windows bootloader partition to install grub.
Now I know I was so dumb doing that.
whats the difference between /etc/binfmt.d/, /proc/sys/fs/binfmt_misc and /usr/share/binfmts?
qemu and python install to usr, wsl and maloader to proc and nothing to etc
shiny.
how did that ruin ur pc?
I Am Not Comfortable
With this interface
At First it was like win xp
Then i customised it
But Still It Looks Ugly
i dont think gentoo linux would be about looks rather than the functionality
Yeh
currently i have ubuntu on my second computer with oracle vm with kali linux and windows 10 vms
yeah i dont think thats meant for devs tho lol
want clean UI use i3. 😛
i have 4 python versions in linux mint
python-3.8.2 (global)
python-3.8.6 (altinstall)
python-3.9.0 (altinstall)
python-3.8.5 (anaconda)
i want to uninstall 3.8.6
please help
Simple
Aww Linux Mint
idk Then
If it was windows i can help
@uncut bloom https://youtu.be/VvFySmPKabg
In this video, you will learn 4 different ways to uninstall programs in Linux Mint. I will also explain to you how and why these 4 ways should be used in my view.
Watch more Linux Mint videos https://www.youtube.com/playlist?list=PLSmXPSsgkZLsiemyy_Rzcqf_0iED8ZfHS
These ways...
@uncut bloom installed from source or from the package manager?
@uncut bloom installed from source or from the package manager?
@opaque ginkgo from source
does it have a make uninstall target?
guys i am using wmic in order to uninstall a package from a computer
the issue i am facing is that
even though sublime text shows up on my programs and features menu, it does not show up in the output from wmic
Solus Os
Solus is so cool. I love it !
Why not Ubuntu?
bloated
haha its ok if you want to get into linux
Yeah it is ideal for that. It's extremely stable too.
For me it's less about bloat and more about "I don't trust Canonical"
That said I do use Mint Cinnamon at home on my "big" PC, I'm a big Mint fan
rolling release distro are the best to me
may I ask help for linux bash here?
@half crow you can. The unix channel isn't python-specific.
:0
then, here we go
Hi~~ As the server rules require, I will try to explain my issue the best I can. Please forgive me if my english is not very good and ask me anything. Thank you in advance.
TOPIC: Log commands from different ssh connections to the bash history files
-
Scenario:
Lot of servers Linux Centos 6/7 with 2 users:norootandroot.
It is required to keep a minimum track on the commands issued in SSH bash sessions, without adding more users to
this servers.
Clients are customizable. -
Idea:
Since there is no problem modifying SSH clients, the main idea resides on taking advantage of SSH's SendEnv feature
to send a variable$GIT_NAMEto the server, previously defined and exported when opening a local bash shell~/.bashrc.Given this situation, what would be the best option to keep a track on every "user" identified with the variable
$GIT_NAME?
-Main approach:
My main approach is to make use of the history command in ./bashrc with
PROMPT_COMMAND=history -a $GIT_NAME.history ; echo $(head -n1 ~/.$GIT_NAME.history) >> .bash_history .
Why like this? Well I can't make it work.
Ideally I would type `history` and the format would be something similar to this one:
https://www.linuxtechi.com/enable-timestamp-history-command/
..,but adding the variable if received.
`.bash_history` writes the timestamp with a Unix Timestamp commented before the line, like: ```
#160005455
sudo shred /etc/*
#160005600
ls /etc/ -lhta
#160005941
echo "OK"

hi I moved to windows... saddly BUT atleast i still have my linux 🙂
i use all my python stuff over here because i have more space but setting stuff up from github is over there
vim goes brrrrr
I'm trying to print the prime numbers and then count of the prime numbers
But this code of mine will print 100 times of every prime numbers...the count prints 100
if you have an upper range, you can use the Sieve of Eratosthenes method. It's much more reliable, faster and cleaner.
def prime(n):
if n == 2:
return True
for i in range(2, n - 1):
if n % i == 0:
return False
return True
This is the brute force way to check if a number is prime
Time Complexity; O(n)
def prime(n):
if n == 1:
return False
if n == 2:
return True
i = 2
while i * i <= n:
if n % i == 0:
return False
i += 1
return True
This is the best way to check a number is prime or not
Time Complexity: O(sqrt(n)
what does exporting a variable do?
@warped wing in the shell?
It makes it part of the "environment" which is inherited by child processes
@main olive Thanks a lot! I've managed to use your code and fix it a little to make it work
def prime(n):
if n == 1:
return False
if n == 2:
return True
i = 2
while i * i <= n:
if n % i == 0:
return False
i += 1
return True
@main olive i remember this answer was part of project Euler.

