#unix
1 messages · Page 29 of 1
@marble bluff i've been told nobody has been able to break it yet, but i also wouldn't rely on it for testing malicious code
okay
The one you linked was an internal command for staff only
snekbox is the public one
would it be preferrable over a docker?
for that matter, should i both have whitelist and sandbox the running or just sandbox it
theoretically the sandbox should be enough but i don't know that much about this process
You could have a whitelist if you want. The way we did it was have nsjail mount the directory in read-only
which really solves a lot of potential security issues already
okay
Maybe you could accomplish that in Docker? I dunno I haven't messed with limits for containers much tbh
so i guess i'll try that and just have input/output in sys.stdin and sys.stdout
But NsJail would let you have way more fine grained control if you need it
okay, thanks for the tips!
you're welcome
We just use alpine images
Personally I'd be fine with debian too
I think they have images with smaller distributions of debian on docker hub somewhere
I also saw a tool in #303934982764625920 recently that helps you build your own minimal base image
any specific reasons for alpine?
okay
I'm in CentOS 7 and I'm trying to create a bash script that launches a few of my python scripts in different screens.
Here is what I have so far :
script1
script2
script3
)
script_names=(
script1.py
launch.py
cook.py
)
len=${#script_names[@]}
for ((c=0; c<len; c++))
do
echo "Starting ${screen_names[$c]}"
screen -X -S ${screen_names[$c]} quit
screen -S ${screen_names[$c]}
screen sh -S ${screen_names[$c]} -c 'python3.7 ${script_names[$c]}'
done```
I can get the screen to open but the python file often runs at the root and nothing happens in the screen
Just as an FYI, screen has been abandoned for a few years now, check out tmux or dtach instead
huh, thanks
basically between like 4 years there were no commits
despite bugs being found
right now there is a bit of activity since but no new release
so Red Hat straight up removed it from their repos
We are running AIX, the gentleman who set our system up was told to install python 3.4.6 and python3.7. However he did this by replacing python 2.7, and only installed python3.7. To make things more interesting we asked him to install pip as well, as he installed the bare min he could.
I did not have access to this server until our main system went live, so I was unable to test it to ensure it was setup, or allowed to set it up myself. I don't know a lot about Unix or Linux, but know I could have installed them both easily. currently when we type pip3 it launches python37. We need to get python 3.4.6 installed to work with our installation of UniVerse, and I am needing Python 3.6+ in order to utilize a lot of my scripts that I have program and to lazy to convert back to 3.4.6.
Any suggestions on wiping python out so I can start over?
Its been an up hill battle since March trying to get it fixed. I been pulling all the data manually and running it within wsl, or windows depending on how it was programmed.
Do you have python3.4 and python3.7 commands available?
They would be in typical python installs from my experience
And if you needed to use pip you could do python3.4 -m pip install ... for example
You weren't clear on what the actual problem was
So 2.7 was wiped out
and python 3.7 was installed as pip3.
pip is no where to be found.
Do you need 2.7 though?
np
pip is for python 2.x
no
So that guy didn't install Python 3.4, but you said you need it. But I don't see the problem there. Can you not just go ahead and install it yourself now?
yes i suppose so
so the pip3, did the guy just rename python37 to pip3?
I mean i know you can see my install or anything
Hmm? I was thinking you just were miswording things
Are you actually saying that the python executable is named pip3?
Collecting pip
Downloading https://files.pythonhosted.org/packages/62/ca/94d32a6516ed197a491d
17d46595ce58a83cbb2fca280414e57cd86b84dc/pip-19.2.1-py2.py3-none-any.whl (1.4MB)
100% |################################| 1.4MB 3.1MB/s
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Could not install packages due to an EnvironmentError: [Errno 13] The file acces
s permissions do not allow the specified action.: '/opt/bin/pip3'
Consider using the `--user` option or check the permissions.```
yes
Does AIX depend on python in any way?
Other distros do and removing it can bork things like your package manager for example
If it didn't come with 3.7, and 2.7 was removed without noticeable issues, then it may be alright
Ah so pip3 is just a symlink to python3.7
guess so
does python3.7 -m pip --version work?
try /opt/bin/python3.7 instead
also its installed in opt/lib, is that normall?
maybe that dir isn't on your path
normal*
/opt/lib/python37.zip
/opt/lib/python3.7
/opt/lib/python3.7/lib-dynload
/opt/lib/python3.7/site-packages```
/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java7_64/jre/bin:/usr/j
ava7_64/bin:/opt/psforms/bin:/bin:/usr/bin:/etc:/usr/informix/uv/bin:/opt/psform
s/bin
$```
Yeah I suppose it's alright that its there
According to the other pic you showed the symlink was to /opt/bin/python3.7
so try the command I showed again but specify that absolute path to the binary
so he installed it multiple places?
No
the binary is in /opt/bin and the things like the standard library files are in /opt/lib/
ok
so does /opt/bin/python3.7 -m pip --version work?
or do you get a module not found error?
pip 10.0.1 from /opt/lib/python3.7/site-packages/pip (python 3.7)
ok so it does have pip
kk
Honestly I'm not sure how you could fix the pip3 command (well you could start by removing the symlink)
but you can just be a bit more verbose in the command and you'll get pip to work that way
never messed with symbolic links on unix or linux just windows
With the command I showed above
If you were to install python 3.4 side by side then you'd need to run pip like that for one of the versions anyway because IIRC version-specific pip commands are not added unlike the python command itself
So it looks like there is a lot of symbolic links here, all the -> correct. I can freely delete these? As for pip3, i still haven't figure out why its going to python3.7
thats in opt/bin
the pip3 when i call it came from somewhere else
that one is actually pip3
Usage:
pip3 <command> [options]
Commands:```
would adding opt/bin to path be wise?
Yeah I'd add it
So you have a pip3 binary and then also a pip3 somewhere else that's incorrectly symlinked?
yea python3.7 is named pip3 in a different directory
alright, my office is being locked up and i don't want to set the alarm so I am out of here. Ill probably be back tonight or tomorrow to look into this more. I think I know what needs to be done.
Yes, exactly
Thanks
So we didn't end up adding it to export. as they are a bit touchy with commands they don't use often. Though I showed how it works in WSL with no issues, and that it just added it to the front of $PATH. However we got our 3.7 working and we have 3.4.6 working
So thanks everyone
Okay so now we tried installing paramiko with pip3 and got this error message about a directory called xlc_r not existing
the compiler from Python's standard "distutils" module. See
the error messages above. Likely, the problem is not related
to CFFI but generic to the setup.py of any Python package that
tries to compile C code. (Hints: on OS/X 10.8, for errors about
-mno-fused-madd see http://stackoverflow.com/questions/22313407/
Otherwise, see https://wiki.python.org/moin/CompLangPython or
the IRC channel #python on irc.freenode.net.)```
full error here: https://pastebin.com/EVQSGsjh
I'm not familiar with AIX. xlc seems to be IBM's proprietary compiler, which needs to be purchased separately?
Maybe you already have it but it's just not on your PATH
If you don't have it then you can look into getting a free compiler to work like GCC
gcc is the gnu compiler collection, its a compiler collection for maaaaany languages including c++
thanks
@visual lark https://i.imgur.com/UhHcr8w.png
Yea, i am looking at http://aixtools.net/index.php/AIXTOOLS to get it installed
what OS are you on?
So looks like i need to download all these http://www.bullfreeware.com/affichage.php?id=5169, then install them.
Not sure if this will cause any issues with our system, but I don't believe it will. We are using UniVerse by Rocket Software.
This may be of interest to you https://www.ibm.com/developerworks/community/blogs/mhhaque/entry/how_to_use_gcc_or_g_compiler_on_aix_7?lang=en
Thanks
Hardest part is, i can't get them to let me install anything unless I have everything perfect for the install and know it wpm
won't affect our server.
I understand
Perhaps you can circumvent the need for a compiler for now
Packages may come with manylinux wheels
I wonder if manylinux wheels work on AIX
I would have expected pip to try to use the wheel by default, but I honestly don't know how it it really does have such behaviour
You can see the wheels here for various versions of Python
and you should be able to do pip install blah.whl to install it
instead of trying to build cffi from source, which requires a compiler
It may not work though since I believe manylinux wheels are built with GCC but AIX uses xlc
I am fairly certain the person who installed python37 originally did it some stupid way and thats why we are having issues
awe
Maybe your initial issues sure. But needing a C compiler to build certain packages is fairly common
It's not related to how Python was installed
k
Needing a C compiler is a separate issue
I would say you may be at a disadvantage cause you're on AIX and it uses xlc
So you may not be able to take advantage of wheels
manylinux ones specifically
Any thoughts on how I would get paramiko installed?
Presumably paramiko has a dependency on cffi
So you need to get cffi installed
cffi is a c extension for Python so you need a c compiler for it
or you need to find it precompiled somewhere (a wheel)
ok
now you can say you use arch btw
@livid nebula
Is that gnome?
Wow, so looks like the guys who work on AIX Tools, released a test version of a precompiled paramiko for python 3.7. http://download.aixtools.net/test/paramiko/. So don't think we are going to install GCC anymore unless we run into more problems. Also more info on their recent forum post here http://forums.rootvg.net/aixtools/paramiko-for-python3/new/#new for anyone who needs the info
Paramiko for Python3
Mine doesn't pick up a whole lot :/
@white solar yea and it virtual machine looking to get laptop for arch have any suggestions for a desktop environment that is easy to set up I'm looking at mate
iand it looks nice
go kde!
jk
but it was the first desktop i've ever used and its awesome
How can I gunzip all files in a directory, but have their destination be somewhere else?
Do i have to write a shell script for it?
I know it has -r but I dunno how to specify a destination
the typical way with a single file is gunzip -c file > /dest/
doesnt gunzip have a "directory" option? like -d or something
yes you'd write a shell script, or at least a more "extended" command
huh i guess gunzip doesnt, i think unzip does
for gz in downloads/*.gz; do gunzip -c "$gz" > src/"$(basename "$gz" .gz)"; done
something like that
find downloads/ -iname '*.gz' -type f -exec gunzip -c '{}' \> 'src/$(basename {} .gz)' \;
yuck... that might work too
"$(basename "$gz" .gz)"
^ that
i'd probably include the src/ in the outer quote, but that's stylistic
does find -exec support redirection?
nope
it just sends the > as an argument, you'd need to start a shell explicitly
and getting {} in the middle of a string is even more of a hassle
-exec sh -c 'gunzip -c "$1" > "src/$(basename "$1" .gz)"' _ {} \;
if you use zsh its a little shorter
for gz in downloads/*.gz; do gunzip -c $gz > src/${${gz:t}/%.gz/}; done
what is _ there @worn apex ?
the first argument after sh -c ... becomes $0
which is normally the script name, as its "argv[0]" eqivalent
TIL
i suppose you could just use it, but it gets trickier with exec + because it doesn't get included in $@
-exec sh -c 'gunzip -c \{\} > "src/$(basename "$1" .gz)"' \;
would that work
err wait no
-exec sh -c 'gunzip -c "{}" > "src/$(basename "$1" .gz)"' \;
i'm not sure I'd trust it
what if the filename contains quotes or other special characters
(I didn't think find could do it at all, but apparently I'm wrong at least about GNU find)
If a utility_name or argument string contains the two characters "{}", but not just the two characters "{}", it is implementation-defined whether find replaces those two characters or uses the string without change.
but it doesn't do anything special with quotes, so that'd be a problem
the answer is, "use zsh"
or i guess you can write the move-file script to a separate file
echo -e $'#!/bin/bash\ngunzip -c "$1" > "src/$(basename "$1" .gz)"' > unzip-to.sh
find directory/ -iname '*.gz' -exec ./unzip-to.sh '{}' \;
ty
hey gius
guys*
I was wondering what environment setup he gots here
it looks like vim and tmux
but his commands doesn't work on my terminal for some reason
like :e file.py
for editing and stuff like that
Hey I have a Chromebook c720 and am installing arch Linux on it. I know the wifi driver I need just can't figure out how to enable it.
Give me your terminal emulator recommendations. Looking for something lightweight. I don't need tiling or tabs because I don't see why my window manager can't handle those jobs. st would be appealing if it had some more basic features like scrollback and copy/paste (I've found forks which have those) but the way it is configured (recompiling) is unappealing to me. Also some of the bugs on the issue tracker put me off.
Alacritty!
wow I was not expecting to get an actually good recommendation
no offense to everyone here
I'm gonna try this out
Alacritty is lightweight? 0.o
I personally use kitty, it does have tiling and tabs functionality though so some might ermagerd bloat
I use tilix currently and it was fine
but yeah I am just thinking about bloat
why do I need to use software with so many features I don't need anymore
st was like halfway there but its a bit too barebones
which is a shame
if you end up trying alacritty let me know if you run into anything buggy, it’s one of the things discouraging me from trying it out
also speaking of many features I don’t need anymore, an i3+kitty+neovim setup let’s me have splits in tabs in splits in tabs in splits in tabs...
I'll be running the same thing except I haven't decided on a terminal yetr
I just don't see the point in tabs and tiling when you're already using a window manager than can tile for you
maybe some people may like tabs? but I don't see the point
I haven’t benched anything, just speculating, but would it be faster/less memory consumption if you use the terminal's own splitting/tabbing vs creating a new separate process?
Maybe not if the terminal has some sort of daemon
but these lighter weight terminals probably leave it out
I'm not concerned about system resources as much as I am about the performance of actually using it
I am guessing the latter wouldn't change with how many processes of it you had unless it ends up impacting system resources heavily
which I don't see ever really happening to me
yeah, alacritty and kitty both offload rendering to the GPU though so if you end up trying both, do share your experience
just installed it so we'll see
I'll probably stick with it for a bit. I really wanted to make st work but the effort into configuring it felt off putting if there was the chance I'd end up just dropping it
But alacritty feels like less of an investment
also I need a better nvim theme cause I am realising this is quite awful with its grey-ness
maybe just changing the bg colour will do it
is that vim-one?
I’m using that too, I think the background uses the terminal emulator's background? because mine isn’t as dark as yours
Yeah you're right it does do that
I've been having trouble staying motivated to do this
All the time I've devoted to making the switch today has been deciding which terminal emulator to use lol
just get overwhelmed and do other stuff instead
just configure stuff one at a time, I get that too sometimes
I'm definitely going way out of my comfort zone
I still have lots to do on my laptop but I’ve been putting it off
that’s good though
I think you were wrong about vim using terminal's bg colour
hm, how does it work then? I didn’t research because I didn’t have any issues 😅
Just seems to be defined by whatever theme you use
like :hi group ctermbg=whatever
the colour schemes just have a bunch of highlight commands
okay, so the error was my assumption due to the fact I’m using the same colours for my terminal emulator and the vim colorscheme I’m using
kind of a pain since I don't even know what groups to edit
how did you install the vim colorscheme?
do you set termguicolors?
yes
hmm
I want to see how it'd look if the window was semi transparent
just set it to black and like 70%
Maybe that's something I need to do in i3 instead
But not sure cause then I'd need to manage exceptions (e.g. don't want my web browser transparent)
what's $TERM?
xterm-256color
you’re not using tmux right?
I’m not sure, I installed alacritty on my machine, and neovim's background does show correctly to the lighter grey
Alacritty's background is black by default
yes, but when I open neovim the background shows up
right then it means like I said, it is not dependant on terminal bg
yep
The way I set my theme is
syntax on
set termguicolors
colorscheme one
set background=dark
is yours any different?
it's the same
well also this let g:airline_theme='one'
I checked the colour code and the bg is the same as the one in their screenshots
Kinda baffling they would choose these colours
this is unreadable
well, barely
no yeah comments are that dark for me too, I was partially blind
I haven’t found a nicer scheme yet though
maybe it’s time to make my own
You can customise it
It has a config function which basically replicates highlight
I'm gonna look into that later
When we do sudo systemctl restart gunicorn-service does it gracefully reload it? Or is there any downtime? I am hosting a new website, its my first time with Gunicorn, have been using uWsgi in past. So i dont know about it, i need no downtime when I launch my site with traffic.
i think restart implies downtime, check if there is a reload or graceful command
reload usually means only reloading the conf, without stopping
@brazen summit restart completes stops and starts the service (by default it sends a SIGINT to stop it IIRC), so yeah there will be downtime
It'll be very short but present
systemctl reload sends a SIGHUP instead, which many processes interpret to just reload the configuration, which may be what you want provided gunicorn handles it
ah thanks!
Has anybody tried to view app cached images in linux?
It's easily done on windows, but on linux apparently files apparenly got extra layer of encryption?
@main olive elaborate?
@main olive It is possible to inspect discord images stored in a cache, even after they are deleted via the app with api call
They are extensionless files on windows, and all you are required to do to view them is to convert them to .png
discord, the client?
yes
the client
point being, on windows it is easy
whereas on linux quite complicated
do you have a file you've grabbed on linux at hand?
couldnt find any info online
yes
run file on it
does it say it's just "data"?
yes
well then
tried converting to any formats it won't work
also, when i do open up the file with text editor
i mean i see so much encoded stuff but also some unencoded urls
http responses
can you do hexdump -C [file] | head on it and post the output?
including the whole url for the file, which is not accessible anymore
sure
I've done it, but it contains a url
🤔
post it
sec
I think @sage solar tried that too some months ago. We didn't find out how it works IIRC.
00000010 40 e7 fa 72 00 00 00 00 68 74 74 70 73 3a 2f 2f |@..r....https://|
00000020 6d 65 64 69 61 2e 64 69 73 63 6f 72 64 61 70 70 |media.discordapp|
00000030 2e 6e 65 74 2f 61 74 74 61 63 68 6d 65 6e 74 73 |.net/attachments|
00000040 2f 35 37 32 38 32 33 31 31 31 31 39 36 37 33 37 |/5728231331196737|
00000050 35 36 33 2f 36 30 38 33 33 33 31 33 36 35 33 34 |563/308333136534|
00000060 39 36 32 31 39 36 2f 69 6d 61 67 65 30 2e 67 69 |962296/image0.gi|
00000070 66 3f 66 6f 72 6d 61 74 3d 70 6e 67 26 77 69 64 |f?format=png&wid|
00000080 74 68 3d 33 30 30 26 68 65 69 67 68 74 3d 33 30 |th=300&height=30|
00000090 30 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 |0.PNG........IHD|```
i am not too keen on insides of the files, such as images and all, but are they even supposed to contain urls when viewing with text editor?
huge portion of the file is encoded or maybe even encrypted
It can contain anything discord wants it to contain
it doesnt look like it's directly an image format
location where you're getting these from?
but the size of the file varies depending on extension of the cached thing itself, gif's are like 300 lines long, whereas regular api calls like avatars are less than a hundred
@main olive ~/.config/discord/Cache
on the user that has discord installed obv
neat, I'll have a look tomorrow, try REing the logic and report back
thanks man
@sage solar any ideas?
I tried what some month ago
I can't recall trying to read images from caches
At all
Not even having the idea of doing that, sorry @main olive
How do you pronounce "chroot"?
c h root
I'd been going with Chi Root, but then I encountered schroot and my brain broke trying to pronounce it.
Chroot is short for change chroot so just ch as in change + root
it's pronounced "groot"
@main olive Checked the average lengths of the files in bytes for each extension it has included inside.
Average length of .jpg file is: 13072.95703125
Average length of .gif file is: 36290.333333333336
Average length of .mp4 file is: 16322.876325088338```
is it even possible that gif takes up more space than mp4
for Cache folder that is
@warped nimbus so all the values look normal to you?
I wouldn't necessarily say normal since I don't know how the images are being stored in this format, but seeing this wouldn't raise any suspicions
@warped nimbus is it even highly possible that linux and windows could have completely different ways of storing cache. Why would discord do that
I don't know. I'm just going off what information you've given us
Have you considered comparing the same exact cached file on windows vs on linux?
Do you see any resemblance of like a PNG header inside the files?
@warped nimbus i am checking it right now
so much resemblance
There is a noticable pattern
but when i sort of correct linux file to match that pattern on windows
and transfer it to windows
it doesnt load it
although the format matches
yes
I use Discord in Firefox. I wonder if its data cache is meaningfully different
are you on linux
I am
No idea how. I'm not exactly a web dev lol
Where would Firefox store cache like that? Under user data?
try ~/.cache/mozilla/firefox
drwx------ 7 keithb keithb 4.0K Aug 6 15:44 n9rkqdzb.default-1505854938711
drwx------ 7 keithb keithb 4.0K Aug 2 14:28 wn279iff.default-release
@boreal kestrel are you good at image files
I wrote a spec once 15 years ago from a reverse engineered image container format
how come i see different symbols when using same text editor in linux/windows both set up to use utf-8
different fonts, different parsing
i guess
realistically you don't want to touch binary data with utf8 encoding
@warped nimbus
i can see both IDAT and IEND
on both linux and windows, meaning those files do contain images
but for some reason only windows manages to convert them corectly
when adding the right extension to the file
in order to view it
you mean python libraries?
yeah
I have literally only worked with those once
linux has no concept of extensions
understood
pass it the file path
However, for info, here's a hex dump from an actual PNG file which I could view:
xxd 443e0b9d71bea893105dade8e907e5c1.png | head <-- xxd is an awesome hexdump tool, I use it almost every day. also the image is "small" but has thousands of hexdump-lines, so head shows just the first 10 lines output
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 .PNG........IHDR
00000010: 0000 0118 0000 00be 0806 0000 00ee bc10 ................
00000020: cb00 0020 0049 4441 5478 9cec bd67 7423 ... .IDATx...gt#
00000030: f979 e6ab 2ff7 eeb9 7b76 d70a b6e5 b565 .y../...{v.....e
00000040: 69ba d989 dd6c b299 90c1 0a40 2114 3250 i....l.....@!.2P
00000050: 4081 0580 0008 1448 0004 d800 53b3 c926 @......H....S..&
00000060: bb7b 3a4e e8e9 093d 7946 9334 1a8d 4633 .{:N...=yF.4..F3
00000070: b265 85f1 d8b2 2cdb 2bc9 96bc f6da 67bd .e....,.+.....g.
00000080: d7e9 782d af9c 641f 5faf efee ddd1 6a9e ..x-..d._.....j.
00000090: fba1 020a 81a1 2339 3de0 39ef 0189 aafa ......#9=.9.....
It looks to me like the URL in the dump you provided would likely indicate it's a custom format.
it won't identify image
@boreal kestrel
your does start with .PNG
as it should right?
i tried deleting that part before PNG
didnt help
Discord likely has a custom format with their own header information to include the URL and likely a checksum too
That's odd.
i have inspected cache files on windows
they didnt have any normal looking
headers
incuding urls
so what do i do
the format is clearly almost the same as in windows
echo -n 'https://cdn.discordapp.com/avatars/128181551472050176/279dc3abe62c43856062e3fd4901a821.png?size=128' | wc -c
= 99
The windows cache files don't have proper image headers either?
your 0x63 is likely the url length
But it still figures it out?
which means you should be able to open the file in binary mode and skip ahead that many bytes
@warped nimbus yes
from there you could hand off the file object to PIL for it to load from there, or you can read the rest of the content as image data
unless changing the format of file strips out some parts
which i would assume it shouldnt
no the extension does absolutely nothing to the data inside if that's what you're asking
Why go through the trouble? They likely directly-appended the PNG data. I wouldn't be surprised if one of the fields even describes how long the PNG data is
windows doesnt have proper headers then
What image viewer program do you use?
Windows doesn't have a lot of proper things. But this isn't a Windows problem 😃
You could be right that they just appended the image data
you'd just need to find where it starts and ends
Though if that was the case you should be able to see huge chunks of similar bytes across platforms
the one on windows
according to
but it still wouldnt load it
on neither linux or windows
i tried many image viewers
i will give an example
Can you try to extract the PNG chunks and the prepend a proper header?
i already have the header on linux file, which i displayed above with xxd, windows file on the other does not have that header
so why prepend
normal as in the one that's working?
Normal as in not even a cache file
just a plain old png you saved from wherever
Like if you look at the PNG spec and then look at what data you have, what does the spec have that you don't?
All it needs is a header plus three chunks IHDR IDAT and IEND
You said IDAT and IEND exist
okay actually i guess it was not related to that at all
might be just Kali problem
because i literally just had test.png image that was displaying just fine
i deleted extension
then added it back
and sure the thing doesnt work anymore
which it would on windows
i dont understand why
@warped nimbus you said extension does not matter
Linux doesn't have any concept of file extensions. Any program which uses a seen extension is malformed
could be that your image viewer program relies on extension somehow
but in terms of the data in the file, that does not change
The file itself should have plenty of information in the content of the file to determine its file type. Where the content is not enough, programs rely on the user to tell it the content type.
yeah that's why things like headers and magic numbers exist
So for PNG files, that's what the header does. The 0x89 followed by PNG.
JPG files have their own unique header
Gzip-compressed files have their own unique header. 7z has its own. Tar has its own. Well-built scripts have their own too
If you're saying that you removed the .png from the name of the file and then a program failed to load it, then I'm saying that program is broken and you should use a better one. 😃
ye, actually just tried another file and it didnt affect it
god damn it
okay well it must be the problem with headers
cat example.py
#!/usr/bin/env python3
import sys, struct
with open(sys.argv[1], "rb") as f:
f.read(8) # skip unknown 8 bytes. probably checksum
f.read(4) # skip unknown 4 bytes. probably versioning.
lenbytes = f.read(4) # apparently these 4 bytes are len. we'll use struct in a bit.
f.read(4) # more unknown bytes
f.read(4) # lol more unknown bytes
# f is now at the URL start.
urllen = struct.unpack("i", lenbytes)[0]
# f.seek(urllen, 1) # from_what == current position
f.read(urllen) # for some reason, I can't seek. oh well, just read and ignore.
#
# f is now at the raw image bytes
print(f.read())
Then:
python3 ./example.py <(xxd -r -p <(echo -n "305c72a71b6dfbfc050000006300000085cfbc680000000068747470733a2f2f63646e2e646973636f72646170702e636f6d2f617661746172732f3132383138313535313437323035303137362f32373964633361626536326334333835363036326533666434393031613832312e706e673f73697a653d31323889504e470d0a1a0a0000000d4948445200000080000000800806000000c33e61cb00002000")) | xxd
00000000: 6227 5c78 3839 504e 475c 725c 6e5c 7831 b'\x89PNG\r\n\x1
00000010: 615c 6e5c 7830 305c 7830 305c 7830 305c a\n\x00\x00\x00\
00000020: 7249 4844 525c 7830 305c 7830 305c 7830 rIHDR\x00\x00\x0
00000030: 305c 7838 305c 7830 305c 7830 305c 7830 0\x80\x00\x00\x0
00000040: 305c 7838 305c 7830 385c 7830 365c 7830 0\x80\x08\x06\x0
00000050: 305c 7830 305c 7830 305c 7863 333e 615c 0\x00\x00\xc3>a\
00000060: 7863 625c 7830 305c 7830 3020 5c78 3030 xcb\x00\x00 \x00
00000070: 270a '.
That would demo how you could parse that weird header. Good luck figuring out what the other fields are tho. They're probably important.
Since I don't have your weird image file on my machine, the <(xxd -r -p <(echo -n "vomit")) takes your hex dump you screenshotted and turns it back into a readable file
but the data from the last f.read() should be able to be saved to a new PNG file. Or directly loaded by something like pillow
why won't just image work when i get rid of headers
they are not important, since windows images dont appear to have them sometimes
How are you getting rid of the headers?
text editor?
what is then?
When I was doing stuff on Windows with binary data files, I found Breakpoint Software's Hex Workshop to be awesome.
I really wish it were available for Linux. I'd renew my license then.
Does it? It really hacks around the header
But the last f.read() should give you all of the raw image which you could save to a new file
right
Out of curiousity, what text editor do you use? On Windows I use Notepad++ to great effect. But again, not for binary data! On the linux side of things, I just use vim
atom
vim is great
but honestly its so intimidating for beginners
so i ditched it
within a week of using
I am aware that it's the most powerful
and all
I just found out about hexedit on debian
I forced myself to learn vim. There's a web game which helps some people learn vim, https://vim-adventures.com/
yes i am aware
@boreal kestrel so could i just delete the headers?
the PNG bit that specifies the extension is not a part of the header
so why keep them
Could you? What do you define to be the header?
Can you select only what you're considering deleting?
Yeah so if you delete everything up-to-and-excluding the PNG header, I would be surprised if the image didn't load after that
PNG is not a header
its part of the Size(12)
whatever that refers to
but it aint the header is it
You are incorrect. The .PNG is part of the PNG header.
so everything until IHDR is a header?
Only you can do what you want to do, I think I've given you an answer already.
[10:14 PM] kinguard: its part of the Size(12)
[10:14 PM] kinguard: whatever that refers to
Size(12) is the Size field and indicates that the bytes in the example represent a value of 12 for the size field.
12 in hexadecimal is C, which you can see in the image as x0C
okay just off topic for a sec
-rw-------
what sorta permission is that
what about the user and others
wait
nvm
it just flew right out of my head that it simply means they have no permissions
😃
i've been on this image thingy for too long
head is melting
how come i can view the image
then
and also edit it
what do you mean?
who owns the image?
it's okay
I went from Mac OS classic to Windows. That was fun. Then Windows to Linux. That was hard. There's a ton of things that Windows hides behind the scenes that Linux expects you to "just" understand. And that just makes it harder to understand where Linux and Windows are actually different too. File permissions is one of those things where Linux and Windows differ a lot.
@boreal kestrel just wanted to let you know that i did figure everything out, big thanks man
yw
file permission is kinda easy tho for unix too
sudo = admin
ls -l for full permissions, just gotta google what each letter means if you arent sure
i think its easier then trying to figure out in windows where its write only/read only ect ect
hey there guys, out of curiosity does any one know bash? i could use some help with a script i'm writing. probably pretty simple, i'm just a dumb dumb.
just ask your question
what are you trying to do, what do you have right now, and what's not right about it
I'm using bash to delete files in AppData, essentially I want to clear the cache in skype/Lync.
the code i have so far is
@echo off
echo Clearing Lync cache...
If %errorlevel%==1 goto Error
if "%LOCALAPPDATA%"=="" Set LOCALAPPDATA=%USERPROFILE%\Local Settings\Application Data
dir "%UserProfile%\AppData\Local\Microsoft\Office\16.0\Lync\sip_*" /b > list.txt
FOR /F "tokens=1" %%i in (list.txt) do del
I'm adapting this from an earlier project from someone else. i just can't figure out how to make it then delete the names it outputs into list.txt I tried simpler stuff but the folders never get deleted
lol that explains the reason why my commands weren't working, sorry about that.
@warped nimbus hi again, pretty silly question, but what is considered open source? Is discord app that is installed on my machine with all the files considered partially open source?
since i sure can't see the backend of API web servers its constantly interacting with, but can i not see the base source code of the app with all requests excluded?
Open source is usually defined by the license under which the program was released
Being able to access the code doesn't make it open source by itself
the open source initiative defines what constiutes an "open source" license
otherwise it's "source available"
i see
but can i inspect the code of discord app
its based on chromium isnt it?
so i would assume i can?
technically you can attempt to reverse-engineer everything
but ToS etc usually don't allow that
and it has nothing to do with "open source", rather the opposite
they make efforts to prevent you from accessing the code, and they don't allow you to look at it, that's not open source at all
even if you had the full source on your drive, and nothing but the license prevented you from reading and copying it, it would still not be open source, because of the license
i see
@robust cave I couldn't wrap my head around why opacity from compton wasn't working properly (it still appears really transparent at high values like 99%) for a few hours and turns out it may be this bug https://github.com/jwilm/alacritty/issues/2254
So that's the first issue I've encountered with it
At least it's already fixed but just not released yet
Maybe it's not even related I dunno 😩
it’s probably that issue, hopefully the new release comes soon
the releases seem to be bi-monthly so the fix may be soon^tm
what phone?
my lg g4 died that way
it was a common issue with them apparently
rip
can you get to the boot menu?
there usually is some button combo yo ucan mash on powerup to try to get there
and then you can factory reset
volume up or down + power yeah
hi, how can i run one python script in a tmux session on raspberry pi (in console only mode)
I've tried making a .sh script and booting that on startup but that bricks it and just makes it infinitely break stuff
the script in question is called "main.py" on /home/pi
generally you want to create a daemon for important services like that. on modern linux distros you would do that with systemd
https://superuser.com/questions/1025091/start-a-systemd-user-service-at-boot
this series of forum posts has some info about making a 'user' service and setting up the system to start your user services on boot
i'll try and mess around with that
Trying to make install python 3.7.2 on fresh ubuntu 18.04 on rpi3. Getting errors related to gcov being undefined. Installed gcov is 7.4.0... why cant python make find gcov?
Hi
I have a unix script like this:
My server is like this:
/home/dom:
-domalert:
-venv
- domalertv3
-app.py
-template
-index.html
-static
-main.js
-style.css
-requirements.txt
and it says it cant access /etc/nginx/sites-enabled/domalertv3
try running your script as sudo
ok
sudo apt install -y supervisor
echo "install supervisor"
sudo touch /etc/supervisor/conf.d/domalertv3.conf
echo "[program:domalertv3]
directory=/home/dom/domalert
command=/home/dom/domalert/venv/bin/gunicorn -w 5 app:app
user=dom
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
stderr_logfile=/var/log/domalertv3/domalert.err.log
stdout_logfile=/var/log/domalertv3/domalert.out.log" >> /etc/supervisor/conf.d/domalertv3.conf```
so
i got nginx working
and everything else
but supervisor log says
I'd argue in this case you should have the relevant files controlled by the dom user instead of just making the service run as root...
Oh right you did
im logged in as the dom user and everything
Good choice 
Yeah it's easy to think sudo solves everything but it can cause more trouble than it fixes...
I'm guessing you double checked that the dom module is accessible from the given directory?
Shouldn't the directory= line be /home/dom/domalert/domalertv3?
Since that's where your app.py is
Haha yeah stuff like that can be the worst
Anyone using Supervisor here? (for running python script as services on linux)
im using supervisor but im a linux noob
Hey I have a question that might not belong here but im going to ask it. If i wanted to install linux on an ssd that had the installer on it how do i do that do i need another usb drive or can i install it to the same drive
an external usb or dvd will be much simpler
it is possible to make an iso file on disk bootable (but difficult)
and you'd have to boot it to ram fully, then unmount it and hope you can still partition the disk, as I had issues with that before
yeah imo if you were going to do this, you should pre partition the drive and put a small partition at the end with the iso on it
then install grub on the drive ahead of time and add an entry for the iso
but a usb drive or something is WAY easier and you dont have to delete then resize partitions
if you have another os already on the system you could boot up a virtual machine and give it the ssd as a drive
is a daemon something that just listens at a port and does actions? can it return information?
@marble bluff A daemon is any program that stays active in the background
Programs that will run in the background without requiring the user to interact with it are considered daemons
And yeah, it can return info or listen to ports, do stuff, etc.
It's just like any other program except you typically don't interact with it directly
can it return data? like if i made a daemon
Like return it where
and asked "what's the result of blahblahblah"
idk
how would it return something
a pipe?
okay
so i can just have it listening at a port and then return information to another script via pipe
Should be able to yeah
@marble bluff if you want some more information, check out systemd for running the daemon and D-Bus or grpc for talking to it
👌
try to install it from the cmdline, see what it says
sudo dpkg -i /tmp/mozilla_style0/mongodb*
@runic shard
aight
style@style:~$ sudo dpkg -i /home/style/Downloads/mongodb-org-server_4.0.12_amd64.deb Selecting previously unselected package mongodb-org-server.
(Reading database ... 183574 files and directories currently installed.)
Preparing to unpack .../mongodb-org-server_4.0.12_amd64.deb ...
Unpacking mongodb-org-server (4.0.12) ...
dpkg: dependency problems prevent configuration of mongodb-org-server:
mongodb-org-server depends on libcurl3 (>= 7.16.2); however:
Package libcurl3 is not installed.
dpkg: error processing package mongodb-org-server (--install):
dependency problems - leaving unconfigured
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Errors were encountered while processing:
mongodb-org-server
;v
@main olive sorry for ping ;v
sudo apt install libcurl3?
np dude
when i tried to run python3 -m pip install -U discord.py[voice] on my centos VPS (yes it has python 3.7.3 installed on it) and i get this: -bash: python3: command not found
@warped nimbus do you know how i could get discord.py on my centOS VPS that has python 3.7.3 on it?
Sorry but why am I in particular being pinged?
not sure why lol
try using python3.7
try whereis python
maybe something is missing from your PATH
well, i managed to get it working
then after starting my bot up via putty, when i close out of putty my bot just stops working
You'd need to create a service for it
You can do it with systemd
Look up tutorials on that
I bet DigitalOcean has one for it
They usually have good linux tutorials
i use PebbleHost VPSes
Yeah I know you don't use DigitalOcean but their tutorials mostly apply to any linux system (sometimes they have some specific DO stuff but you can just skip it)
oh ok
ok
@main olive
then after starting my bot up via putty, when i close out of putty my bot just stops working
one way of doing it is services, like Mark said
but you can also run your bot in a screen session, that way you can detach and reattach to the console (if you need that)
oh ok
i installed screen
okay, now just run screen python [whatever bot]
done
in the new session, you can detach from it by doing CTRL-A-D
and reattach with screen -r
works? @main olive
yea
awesome
closing putty counts as "detaching" so it won't close the bot
then how do you reattach to that screen after you've exited PuTTY
next time you ssh in, you can just resume the session
again, with screen -r
then what if you have two screens for two bots?
you get something like this
so, how do you make more than one screen?
https://asciinema.org/a/mlnI7Yb7T7enWDQl5xmJNlx8d -- how to reattach to a screen when you have multiple
https://asciinema.org/a/Hl0rrEK5gedoWy2Ykyf3uga33 -- how to make multiple screens
every time I detach, I'm just doing ctrl-a-d
oh ok
you can also just create them detached from the get go with the -d flag
well, the screen i end up making for one bot is screen: 0 and when i attempt to make another, it goes to screen: 0
wat
i've detached from 32XX in my VPS, so how do i create another screen for my 2nd bot?
just run screen on your second bot?
the 32XX whatever is the process ID
it's unique per spawned process
you can also name a session when starting it with -S name
so, like screen -d -S bot1 python3 [whatever the fuck]
names it bot1, and starts it already detached
oh ok
screen -S bot1 python3 <ect> will work the same but won't start as detached?
yep
whenever you have a question, just try it out bro
ok
got it working man?
@main olive I have been contemplating using a terminal multiplexer over creating new terminal instances, what does screen offer over tmux, or vice versa?
if you're picking up a new tool, use tmux
the only reason i don't use tmux is because i'm stubborn and too used to screen
thanks for the input
@robust cave additionally, I use screen very often anyways to connect to serial devices, so why learn something new?
@main olive Just get a different distro that supports latest python then
you're out of luck then if they dont have debian xenial
try somewhere else where they offer actual decent systems
Dunno
@main olive yes
i recommend using pyenv to manage python on debian
let the system python just be the system python. basically ignore it
pyenv install 3.7.3 or whatever version you want, and use that for any dev work
then your dev version of python isn't tied to whatever the system happens to need
pls ping me if you have solution
Hey I've been trying to upgrade my system (I'm under arch) but jsut before it finishes I get this error: ... python-attrs: /usr/lib/python3.7/site-packages/attr/filters.pyi exists in filesystem python-attrs: /usr/lib/python3.7/site-packages/attr/py.typed exists in filesystem python-attrs: /usr/lib/python3.7/site-packages/attr/validators.py exists in filesystem python-attrs: /usr/lib/python3.7/site-packages/attr/validators.pyi exists in filesystem Errors occurred, no packages were upgraded.
From what I understand it's because there are already files which weren't thought to be there. However I don't understand why this is so. What mistake could I have done while doing some python that would cause this?
how are you upgrading it?
have you tried running pacman -Syu again?
yes twice
if you query one of the files for example pacman -Qo /usr/lib/python3.7/site-packages/attr/filters.pyi, is it owned by a package?
no
have you installed anything into your Python installation with pip instead of pacman?
it's most likely that the files shown in the error was going to be provided by one of your packages through pacman, but pip already has them installed. therefore, it detected a file conflict and will not overwrite the files by default to prevent breaking something
so if all the modules are installed are just for scripts ran on occasion and manually it will not break my system?
all the modules I installed through pip are the ones I use for those projects
maybe doing a user install will be safe
but you really should be using virtual environments
i'm trying to use nsjail, but i'm not sure how the chroot works
made adirectory /chroot/
in it i put bin with bash inside
and lib with the things that ldd said i needed
but when i run nsjail -Mo --chroot /chroot/ --user 99999 --group 99999 -- bash -i
it says that [E][1] void subproc::subprocNewProc(nsjconf_t*, int, int, int, int)():194 execve('bash') failed: No such file or directory
does anyone know how i'd goa bout fixing this
in this tutorial, is /alpine the name of the chroot directory? i'm a bit confused, as earlier they said a variable and now they have /alpine
i'm not actually sure, can i even have a chroot with alpine running on a different distribution?
First error is probably because it expects an absolute path to the bash binary
Or maybe it's not on path
If this is running inside alpine then you should know alpine uses ash not bash
@tender anvil to reiterate what others have said:
- Never ever use
sudo pip, it can break pretty much everything. This is what I suspect happened here. Your best bet is to uninstall everything you installed this way. pip install --useris safer because it installs to your user directory, but you can still have issues with conflicts and the like.- The safest solution is to use virtualenvs for everything. This is what I personally do:
- Use pipx for installing Python CLI programs, it'll automatically use venvs for them all.
- If you're trying to set up a new project, check out Poetry, which is an absolutely amazing Python project manager that handles dependencies well and automatically virtualenv's everything.
- If you want just a generic virtualenv, check out mkvirtualenv for a nicer interface.
i don't know who wrote this but it's got many errors
@marble bluff check out my script for setting up a chroot
all you need is the alpine rootfs extracted somewhere
I've used the Alpine guide there before, it worked for me...
@torn snow @warped nimbus Thanks for the advices I'll try to learn of venv works before using other tools.
hello
!ask
ask
Asking good questions will yield a much higher chance of a quick response:
• Don't ask to ask your question, just go ahead and tell us your problem.
• Try to solve the problem on your own first, we're not going to write code for you.
• Show us the code you've tried and any errors or unexpected results it's giving
• Keep your patience while we're helping you.
You can find a much more detailed explanation on our website.
can someone help terminate the terminal opened by appscript.app('Terminal').do_script('python pathname')
how do I get the PID of a certain app using python?
try pythonw? pid should be in ps
@edgy minnow
i have a command which gives me the PID of the application but in terminal
is there anyway I could run that command in python to get the number?
like when i do 'ps -A | grep -m1 path | awk '{print $1}''
it prints it out in terminal
check out the subprocess module
@robust cave i have it dont work (or im dumb)
theres psutil
>>> psutil.pids()
[5034, 14581, 14734, 30719]
>>> p = psutil.Process(14734)
>>> p
psutil.Process(pid=14734, name='python', started='22:43:08')```
I think youd have to iterate over that list, if not use subprocesses to just run ps
@edgy minnow i have the name of the file
/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.fr
is there like a getpid(/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.fr)
or kill (/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.fr)
does ps show enough in name? or does it just say python
in terminal can you type ps
okay
PID TTY TIME CMD
30158 ttys000 0:00.03 -bash
30192 ttys000 0:41.53 /usr/local/Cellar/python@2/2.7.16/Frameworks/Python.fr
30194 ttys001 0:00.01 -bash
30200 ttys001 0:50.80 /usr/local/Cellar/python@2/2.7.16/Frameworks/Python.fr
30205 ttys002 0:00.04 -bash
anyway in python with psutil
iterate the pids & one of the p.exe()'s and/or p.name() should match that
@edgy minnow so if I do
import psutils
name = p.exe()
ill get the name?
pid*
with a for loop
for i in psutil.pids():
p = psutil.Process(i)
print(p.name())```
@edgy minnow will this print all of the pids?
or only 30158 ttys000 0:00.03 -bash
30192 ttys000 0:41.53 /usr/local/Cellar/python@2/2.7.16/Frameworks/Python.fr
30194 ttys001 0:00.01 -bash
30200 ttys001 0:50.80 /usr/local/Cellar/python@2/2.7.16/Frameworks/Python.fr
30205 ttys002 0:00.04 -bash
or those ^
can add an if check & use p.kill(). yea itll print the name of all of them
well should be just those 5 afaik
so if i kill them its gg
sudo touch /etc/nginx/sites-enabled/domalert
echo "server {
listen 80;
server_name 45.7=;
location /static {
alias /home/dom/domalert/domALERTV5/static;
}
location / {
proxy_pass http://127.0.0.1:5000;
}
location /socket.io {
include proxy_params;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:5000/socket.io;
}}" >> /etc/nginx/sites-enabled/domalert
cat /etc/nginx/sites-enabled/domalert``` any reason as to why this script echos the text to the file like this ```server {
listen 80;
server_name 457.57;
location /static {
alias /home/dom/domalert/domALERTV5/static;
}
location / {
proxy_pass http://127.0.0.1:5000;
}
location /socket.io {
include proxy_params;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade ;
proxy_set_header Connection Upgrade;
proxy_pass http://127.0.0.1:5000/socket.io;
}}```?
ignore the server_name I redacted that
need to escape the $
@edgy minnow how do i install psutils
thought it was stdlib & builtin? if not try pip
@edgy minnow what do you mean?
name 'psutils' is not defined
https://github.com/giampaolo/psutil/blob/master/INSTALL.rst says it works on mac...
ImportError: No module named piputil?
@edgy minnow its not working :/
i need to import piputil?
pip install psutils
done
oh ok
wait @edgy minnow
ERROR: No matching distribution found for psutils
but it worked for psutil
oh my bad no s
okay
import subprocess
from subprocess import call
import appscript
import piputil
appscript.app('Terminal').do_script('python //Users//myname//Desktop//FacialRecognition.py')
while True:
for i in psutil.pids():
p = psutil.Process(i)
print(p.name())
is this correct?
shouldn't need the while. & is there no way to have the FR.py close itself?
not familiar with appscript btw
@edgy minnow ya but the for i in psutil.pids():
p = psutil.Process(i)
print(p.name())
will run too fast
it takes a second for facialregocnition
yea that looks fine
tried pythonw?
you have piputil instead of psutil
location /socket.io {
include proxy_params;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade\$;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:5000/socket.io;
}}" >> /etc/nginx/sites-enabled/domalert```
like that?
what?
import piputil
your import
\$http_upgrade
oh ok
import subprocess
from subprocess import call
import appscript
import piputil$http_upgrade
appscript.app('Terminal').do_script('python //Users//myname//Desktop//FacialRecognition.py')
while True:
for i in psutil.pids():
p = psutil.Process(i)
print(p.name())
like that?
no was answering their q too. change that import to psutil
Hyper have you ever used nginx/flask/gunicorn with socketio?
dont think so no
ahh damn ok
you can check against the name
if p.name() == '/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.fr':
print(i)```
But it’s name is just python
@edgy minnow it is still fine?
Like it prints just python
what does .exe() print?
Idk I have to leave now because I have to leave now 😢
Not my choice
I’ll be back in 20-30mins
well check exe, python wont work right as theres a specific one you want
if I'm not on later... if theres just 2 python pids you can get the current scripts one with os.getpid() so ignoring that one the other would be from the other one
@edgy minnow just to confirm the script should look like this:
echo "server {
location /socket.io {
include proxy_params;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:5000/socket.io;
}}" >> /etc/nginx/sites-enabled/domalert```
so the end result is this:```
echo "server {
location /socket.io {
include proxy_params;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:5000/socket.io;
}}" >> /etc/nginx/sites-enabled/domalert```
because I tried the script like that (first embed) but it resulted in in like this:
server {
location /socket.io {
include proxy_params;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection Upgrade;
proxy_pass http://127.0.0.1:5000/socket.io;
}}```
escape the "s too there & should be fine
@edgy minnow you there?
yea
when i do
while True:
for i in psutil.pids():
p = psutil.Process(i)
print(p.exe())
it says
psutil.AccessDenied: psutil.AccessDenied (pid=0)
something running as superuser perhaps?
maybe wrap a try/except or skip 0...
for i in psutil.pids():
if i != 0:
p = psutil.Process(i)
print(p.exe())```
@edgy minnow it says the path
now how do i get the PID
raise ZombieProcess(proc.pid, proc._name, proc._ppid)
psutil.ZombieProcess: psutil.ZombieProcess process still exists but it's a zombie (pid=31680)
but what is this?
i will be the pid, so you can add the if there. no idea what that is.
are you getting 1 matching path?
for i in psutil.pids():
if i != 0:
if p.exe() == path:
print(p.pid)
this right?
@edgy minnow
with path being the thing you want to match yea
and indent the print
after a : the next line moves in >
ye
for i in psutil.pids():
NameError: name 'psutil' is not defined
@edgy minnow
nvm found it
if p.exe() == "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.fr":
NameError: name 'p' is not defined
got it again
can any1 one help
im getting this error
File "/usr/local/lib/python2.7/site-packages/schedule/init.py", line 563, in run_pending
default_scheduler.run_pending()
File "/usr/local/lib/python2.7/site-packages/schedule/init.py", line 94, in run_pending
self._run_job(job)
File "/usr/local/lib/python2.7/site-packages/schedule/init.py", line 147, in _run_job
ret = job.run()
File "/usr/local/lib/python2.7/site-packages/schedule/init.py", line 466, in run
ret = self.job_func()
File "/Users/Gitansh/Desktop/Main.py", line 22, in stop
if psutil.Process(i).exe() == "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.fr":
File "/usr/local/lib/python2.7/site-packages/psutil/init.py", line 773, in exe
exe = self._proc.exe()
File "/usr/local/lib/python2.7/site-packages/psutil/_psosx.py", line 339, in wrapper
return fun(self, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/psutil/_psosx.py", line 420, in exe
return cext.proc_exe(self.pid)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 35, in exit
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python2.7/site-packages/psutil/_psosx.py", line 370, in catch_zombie
raise ZombieProcess(proc.pid, proc._name, proc._ppid)
psutil.ZombieProcess: psutil.ZombieProcess process still exists but it's a zombie (pid=35038)
You're trying to analyze the state of a zombie process
yeah something you did elsewhere in your program caused the process to become a zombie, which i think means the process is intended to be closed but has not done it yet and lost its parent process
Ah okay
Does anyone know why i can't run this executable?
adam@vmi261078:/usr/local/bin$ sudo chown adam:adam sharpops
adam@vmi261078:/usr/local/bin$ chmod u+x sharpops
adam@vmi261078:/usr/local/bin$ sharpops
-bash: /usr/local/bin/sharpops: No such file or directory
adam@vmi261078:/usr/local/bin$ ls -l
total 24172
-rwxr-xr-x 1 root root 16168192 Jul 26 22:25 docker-compose
-rwxrwxrwx 1 adam adam 8574154 Aug 17 21:24 sharpops
drwxr-xr-x 3 sharpops sharpops 4096 Aug 17 21:24 sharpops-data
adam@vmi261078:/usr/local/bin$
I have seen this exact issue three times an I cant remember the fix, I should write it down at some point.....
wdym?
file sharpops
adam@vmi261078:/usr/local/bin$ file sharpops
sharpops: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/
ld-, not stripped
Hm, I remember the issue being a 32 bit thing once but this seems to be fine
fuck
can you check it with lld as well?
