#unix
1 messages ยท Page 22 of 1
we need more unix up in here..

:nixdab:
Suprisingly quite here
in LVM, how can I remove a disk that was unmounted previously?
LVM still thinks the disk is active for some reason
$ sudo vgs
/dev/sdb: open failed: No medium found
VG #PV #LV #SN Attr VSize VFree
buster-vg0 1 5 0 wz--n- <1.82t <1.33t
sdb was an external HDD with another vg
Did you create a volume group just for sdb ?
It's been a while since I had to use LVM
I googled it and I think this might do it
vgreduce buster-vg0 /dev/sdb
but there might be more to it
See if this helps: https://www.thegeekdiary.com/centos-rhel-how-to-remove-physical-volumepv-from-volume-group-vg-in-lvm/
To remove any physical volume in a volume group vgreduce command can be used. The vgreduce command shrinks the volume group by removing one or more PVs. We can then either use these free PVS in another VG or remove them from the LVM configuration.
The issue is that the device is already gone
so all the commands that operate on it don't really work
Gotcha: https://serverfault.com/questions/421776/removing-vg-and-lv-after-physical-drive-has-been-removed
WARNING: dmsetup can wreck serious havoc with your disks so anyone using this information in the future please make sure you read the man page.
That sounds dangerous
I don't see anything related to sdb in dmsetup ls sadly
only the underlying crypt disk and my active lvs
$ sudo lvchange -a n /dev/sdb
/dev/sdb: open failed: No medium found
Volume group "sdb" not found
Cannot process volume group sdb
What do you get with this?
dmsetup info
does your volume group show in /dev/ as /dev/buster-vg0 ? I forget how VG's show
where do i put py3status module? i can't find anything about path in the docs
Thinking about installing linux on my computer and gonna try to stick with it this time. Any suggestions on distro? I would like to be able to play csgo and dota 2 and I am not sure if distros differ for this (I guess they shouldnt differ much). I have always used ubuntu in the past, should I try something else?
My daily driver is Ubuntu. It'w probably the one you will get most support for, and it's designed to be rather easy to use.
Y I might go for that unless someone can give me a good reason to go for something else. I mean why make linux harder by not choosing ubuntu ๐
There are so many distros out there. If you do the research, you may find something you like more than Ubuntu. But if you don't feel like going through all that, Ubuntu is a safe choice
The support argument is good - Ubuntu is a very popular distro
I've worked with Red Hat 5 and 6 for a few years and thought I should learn about 7, installed CentOS 7 at home and tried to setup Plex. I got Plex working, but for some reason, it won't connect to the network on the Ethernet port, only wifi, which I don't want for a media server.
So, I'm going to just install Ubuntu
I'll learn RHEL7 at work when I need to, at home, I'm going to use Ubuntu
It has great support, great repos and a ton of software.
CentOS and Red Hat need EPEL to get a lot of "non-standard" software, like VLC... which can be a pain to juggle sometimes.
Do I get XYZ package from EPEL or the OS repos? Do I need a third or fourth repo to get the packages I want? Or do I build from source? All of those questions are moot when you have Ubuntu, I've rarely had to add a repo to apt for software
and that's just my 2 cents..
๐
As someone unfamiliar with kubernetes, can anyone translate this for me? https://blog.ubuntu.com/2019/02/28/canonical-adds-containerd-to-ubuntu-kubernetes?utm_source=MOTD
Like why would I want to run my Python stuff in a kubernetes containerd instead of a docker
https://blog.docker.com/2017/08/what-is-containerd-runtime/ might be interesting to understand it? haven't fully read it yet
I'm not great with shell
But I'm trying to edit a environment variable, and then store it again
echo 'export BRANCH="${$CIRCLE_BRANCH |sed 's#/#\-#g'}" >> $BASH_ENV
This should covert a branch name / to .
But my quotes are terrible.
Can anyone show me how I would fix it? thanks in advance
The error is a quote-mark error
@gritty stirrup change ${ ... } to $( ... )
echo export BRANCH="${CIRCLE_BRANCH}" |sed 's#/#\-#g' >> $BASH_ENV
${} is only for expanding variables
well, this is static though
it expands CIRCLE_BRANCH immediately and writes its current value to your file
whereas your previous attempt would read it from the variable every time the BASH_ENV file is sourced
not sure which you want
I will find out when my pipeline fails hahaha
How do u guys use netflix in linux? For the moment I use chrome (which I really dont want to do but dont got much choice)
Found a way to add it to my launcher ๐
I think chrome is the only way to do it with hardware acceleration @wary barn
Actually scratch that
Netflix and linux do not work well in harmony
Chrome is the only supported browser yes
yes but there is a plugin for 1080p
dont know if it works tho as I so far only watch star trek voyager which is not even 720p
I dont think atleast
Not familiar enough with it to know how it effects the quality of life in netflix
Is this for watching on TV or at a desk?
@wary barn I run Debian Unstable on servers and desktop, i have switched my ubuntu server to Debian when ubuntu started putting ads into t he server motd. ubuntu is probably a better first pick for desktop though
Y I will keep using Ubuntu unless I find a good enough reason to switch
read -p "Please enter the path for RethinkDB: " -r
$WIND_PATH=$REPLY |sed 's,\,\\\\,g'
echo "RethinkDB="$WIND_PATH'\\rethinkdb.exe'"" >> .env
The problem here is $REPLY = C:\Users\McArthur\projects\database\rethink
I don't know how to stop $REPLY being interpreted, as a directory, instead of a string
Are you trying to pipe the value of reply into sed?
$WIND_PATH="$(echo "${REPLY}" | sed 's,\,\\\\,g')"
That makes sense. Thank you
And yeah added the echo in there too
sed: -e expression #1, char 10: unterminated `s' command
@warped nimbus
$WIND_PATH="$(echo "${REPLY}" | sed 's,\,\\\\,g')"
What do you mean?
scripts/deploy.sh: line 38: =C:\\Users\\McArthur\\projects\\database\\rethink: No such file or directory
$WIND_PATH="$(echo "${REPLY}" | sed 's/\\/\\\\/g')"
That's line 38
When doing assignment, you don't need the $ in front of the variable name
You're welcome
Now to do it all again in powershell hahaha
PowerShell is easier to grasp than shell scripting IMO
It's like a mini C# or something
yeah power shell treats stuff as actual objects with properties which is kind of nice
but its syntax and how it exposes and names stuff isnt great
Anyone know how I can find the path to a certain systemd unit file?
Sometime I made a while back is now failing and I want to see what's inside so I can debug it
No idea where it is though
I've checked /etc/systemd/system/
systemctl list-unit-files --type=service maybe?
also there might be some in /lib/systemd/system/
Ah it's actually a mount point generated by fstab, not a service
Though I was supposed to create a service too
So it's probably not working cause the service doesn't exist :\
Everything just took a huge dump
*this channel needs more unix.. *

can you reply to my question in the help channel where you asked the same question?
@main olive
Okay so
I started in #help-grapes but was told help would be better for me here with this
So I installed pillow to my VPS that my bot is hosted on. And then tried to reload the cog that uses it. (Note this works on my pc when I local hosted it) But when I tried reloading the cog that was going to use pillow I got this error
Ignoring exception in command reload:
Traceback (most recent call last):
File "/home/container/discord/ext/commands/core.py", line 62, in wrapped
ret = await coro(*args, **kwargs)
File "bot.py", line 253, in reload
bot.load_extension(extensionn)
File "/home/container/discord/ext/commands/bot.py", line 696, in load_extension
lib = importlib.import_module(name)
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/container/cogs/leveling.py", line 11, in <module>
from PIL import Image
File "/home/container/PIL/Image.py", line 94, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (/home/container/PIL/__init__.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/discord/ext/commands/bot.py", line 898, in invoke
await ctx.command.invoke(ctx)
File "/home/container/discord/ext/commands/core.py", line 1026, in invoke
await super().invoke(ctx)
File "/home/container/discord/ext/commands/core.py", line 611, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/container/discord/ext/commands/core.py", line 71, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ImportError: cannot import name '_imaging' from 'PIL' (/home/container/PIL/__init__.py)```
I was told to apt install python-imaging by one person but Mr. Hemlock said apk would be the correct thing as the sever i host on using linux, alpine
But apk is an unrecognized thing
ping when responded to please
https://unix.stackexchange.com/questions/338962/install-apk-tool-on-alpine-linux
and try apk install py3-pillow once thats done
anyone know the default script that is run when i ssh into my Ubuntu 18.04.2 server
watcha mean cap?
well i want my .bashrc script to be run everytime i ssh into my vps
but ive tried putting the command to run it in all of the profile files
(.profile, .bash_profile, .bash_login, /etc/profile)
ah so which shell profile is loaded
and none of them worked
that's a bit odd
so i made a custom script to run it
and it works
but I dont know if i messed things up
because the stuff that used to happen when i log in doesnt happen anymore
like all of the info about my system doesnt show up
so obviously there is a script that isnt being run anymore
there's a different between tty and non-tty ssh sessions, one of them ignores some files...
I looked that stuff up some time ago, but remember only half of it
yeah, i think you can explicitly enable it by specifying the login is via interactive shell
but that's only half a solution imo
why not rely on ssh/rc
add commands in there to load the standard profiles
i checked and i was in an interactive login shell
ive tried all those things lmao
it's odd how inconsistent things are between versions the more i look into it
at any rate, if rc loaded always before, why not just add the command to load the others in there?
it is in there
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
thats what my rc file looks like
and the bashrc profile wasnt being loaded
hm wait i have an idea
that didnt work
now im wondering if maybe it is being run, but the way im checking if its run is being overrun by something else
lol what if it's overwritten by another thing
what im wanting is for my PS1 variable (the prompt) to change
wouldn't it be better to just set a certain unique envar
because right now it looks like this https://i.imgur.com/91rCy22.png
which is unhelpful in telling me anything
but when i source .bashrc it look slike this
which is what I want
but when i tried just changing PS1 in rc, it was being changed (when i echo'd it , it showed the correct value), but it still didnt change the prompt
and when i source the rc file, it changes to the correct prompt
im so confused
yup, .bashrc IS actually being run, but something is overwriting the PS1 variable
that sounds like it is NOT being run but if you think its being overwritten check ~/.profile ~/.bash_profile /etc/bashrc /etc/bash_profile /etc/profile and so on
there is documentation online but tldr bash is stupid and there are a ton of places it might load and it changed depending on how you log in...
ive looked at all of those files though
and i know its being run because when i echo in the file it actually echos
ah echo in the script i see. so it prints out whatever when you create a new shell instance?
in that case id look up the bash profile loading order and browse all the files to make sure you didnt miss one. it might be loading them in an unexpected order so figure out what order it loads the system vs user ones
if it prints out when you create a new shell instance then its certainly another script overwriting it. but make sure you are testing by sshing in, creating a new terminal window etc
it still prints out in another window
and i didnt forget any scripts 
hmmm
i have an idea
Why do the stupidest smartest things always work
i just set the PS1 variable in /etc/environment and it works
thats all i really wanted anyway
why didnt i think of this sooner
I have a silly question.
I'm working on a box that I don't have admin rights on, just user.
I'm trying to get the f5-sdk module installed in my home directory so that I can use it for ansible. But I'm new to python and may be getting tripped up in naming trying to get this to work.
I've grabbed the source from pythonhosted.com and put thm in my home dir.
I've run "python setup.py install --prefix=~/python" and installed them, but ansible-playbook does not seem to know they are there.
I've tried adding the library path for ansible and the PYTHONPATH variable to the site-packages directory under ~/python and it doesn't work.
I'm sure this would be straightforward to someone more familiar. Is there a resource you can point me to to get me sorted? an Example?
File "/home/container/discord/ext/commands/core.py", line 62, in wrapped
ret = await coro(*args, **kwargs)
File "bot.py", line 253, in reload
bot.load_extension(extensionn)
File "/home/container/discord/ext/commands/bot.py", line 696, in load_extension
lib = importlib.import_module(name)
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/container/cogs/leveling.py", line 11, in <module>
from PIL.Image import core as _imaging
File "/home/container/PIL/Image.py", line 94, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (/home/container/PIL/__init__.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/discord/ext/commands/bot.py", line 898, in invoke
await ctx.command.invoke(ctx)
File "/home/container/discord/ext/commands/core.py", line 1026, in invoke
await super().invoke(ctx)
File "/home/container/discord/ext/commands/core.py", line 611, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/container/discord/ext/commands/core.py", line 71, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ImportError: cannot import name '_imaging' from 'PIL' (/home/container/PIL/__init__.py)``` @edgy minnow So we've tried installing it to the build and a good bit of other things but we still get this error
any chance you installed Pil & Pillow?
if not looks like that line94 if you switch _imaging and core
@edgy minnow Didn't work Failed to load extension cogs.leveling. Traceback (most recent call last): File "bot.py", line 47, in <module> bot.load_extension(extension) File "/home/container/discord/ext/commands/bot.py", line 696, in load_extension lib = importlib.import_module(name) File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/container/cogs/leveling.py", line 11, in <module> from PIL import Image File "/home/container/PIL/Image.py", line 94, in <module> from . import core as _imaging ImportError: cannot import name 'core' from 'PIL' (/home/container/PIL/__init__.py)
How do I know if pillow and PIL are both installed?
pip list
would seem I have pillow
and not pil
but it works on my local hosting just not on the server
which I dont get
is that a folder called PIL?
Yes
venvs for python 3+ don't work
python 3.7 -m venv says that it exited with non zero status code
virtualenv -p python3.7 venv raises a shutil file already exists error
you need to specify a path when using venv
python3.7 -m venv /path/to/new/virtual/environment```
Is there a way to pass a env file in the command line?
Like in docker I can do --env-file filename.env, anything like this for python?
@rapid sable https://github.com/theskumar/python-dotenv
Saw this @nimble quarry and am using it now. No native support for this?
@rapid sable well, you can use the usual source way:
source file.env && cmd
e.g.:
$ echo 'HELLO=world' > test.env
$ source test.env && echo $HELLO
world
ah true, thanks
I use bash env $(cat .env | xargs) python script.py
That way the env vars only apply to a specific process
Or just use a subshell ( source file.env && python script.py )
(assuming bash or compatible shell)
@warped nimbus yeah that sounds like the best solution here, you might also define a script to simplify the call
Perhaps it could be done with just an alias
subshell sounds like an even simpler solution though I'm not sure of all the implications using a subshell would have
shouldn't cause any problems, as the Python process is separate anyway
one more layer in between doesn't change anything regarding what the python script can do or not
pyenv is messing with my life ๐ก https://paste.pythondiscord.com/afacozohos
If I activate a venv, pyenv just overwrites it anyway
.venv/bin is clearly on the path but things like gunicorn aren't recognised
For context, this venv was created by pipenv
Ok, even with pyenv disable I still can't use gunicorn
what gives??
It's like activating the environment does absolutely nothing
Ok, sure enough it's just pipenv creating busted virtual environments. thanks pipenv
whats the deal with this?
@jolly wolf apt-get?
do you have python installed, and if so, can you directly use it as a module through it
i do have python installed i think
python3 --version perhaps?
i installed python3 im installing python now
@jolly wolf your running mac correct?
no, linux
if you have python 2.7.9+ i'm sure it has ensurepip
what distro?
does python not work?
im sure it does
sudo apt install python3-pip
python --version says?
2.7
2.7.?
..
15
thank you
rc1
idk thats what it says
python -m ensurepip
says its disabled
oof
python -m ensurepip --enable?
did you do apt update first
sudo apt update
sudo apt update
actually, i'd prefer it if he didn't do it and it works
because after that i don't know anything more
ay it works
short of rebuilding the system python
thanks!
yw
for reference kazo, the apt update command is for updating package lists
not the packages themselves
so try use it everytime you go to install things if it's been a while
oh okay
yea this is my first time using linux in about 5 years and i barely used cmd then
so i dont know a lot
you'll get the hang of it
if you want some pointers dm me @jolly wolf
i'd rather encourage keeping the help in here where possible
it benefits the general community better then
yea, i think id rather keep it here too, just so i could get second opinions when i dont know i need one
๐
this channel needs more unix..
@main olive Why do you keep repeating that?
really?
lol.. I dont know.. it always gets me down this is the least active channel.. There used to be a small unix discord but it's not there any more..
feels like this is the last stand :v
There's quite a big linux discord.. Not sure wether it's official
It's linux as opposed to *nix, but eh.
there are quite a few discord communities centered around a Linux distro, or Linux in general. I run one myself.
hi gang
im using telnet to login to something
is there a way to telnet (ip) and then login (pw) in one command?
really? Im on one linux discord.. gentoo linux.. doesnt seem to be very active
that is one of many
@latent hamlet I'm guess it's similar to SSH, where you can't do that with the bash command
I'd suggest looking for a python package
Like paramiko for SSH
There was a way you could use expect but it was a bit messy to setup.
I am trying to setup a script to clone a private git repository on github. I have setup a pair of ssh keys that work normally (I can do git clone ssh_gitlocation) however when I put the same command in a script it does not work
The script I am using:```bash
#!/bin/bash
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
cd /home/pi
sudo rm -r DatabaseEndpoint
sudo git clone git@github.com:xedre/test.git
Could sudo have something to do with it?
?
Have you tried cloning without sudo
np
how do you use regex with grep
I dont even know which regex type to use with grep x.x
is it perl..
anyone? :v
I want to do this
find dirnamehere -type f -exec grep 'name: "\d+"' {} +
but \d+ probably isnt right
...well is it? does it work?...
- is not interpreted by basic regex flavour
you can either use \+ in basic flavour or switch to extended with grep -E
and \d is only recognized by PCRE-compatible flavour, so grep -P is needed (which includes everything -E supports)
or you use [0-9] instead
any of these should work: grep '[0-9]\+', grep -E '[0-9]+', grep -P '\d+' @main olive
is it possible to use philips hue motion sensor a script trigger on a linux system. i am not familiar with their api
doesnt work for me :<
not sure what I'm doing wrong
find dirname -type f -exec grep 'name: "[0-100]+"' {} +
oh wait.. got it
Do you want the output of dirname?
I don't know, maybe look at the man page?
-type f -exec grep -E 'name: "[0-100]+"' {} +
this worked
how do I access the man page
man grep ?
Yes
oki
There are also a number of websites that host the manpage
oh cool.. that's useful
You can also search in the man viewer
Can't recall how, it'll show you if you press h or something
hmm.. I'll use the websites.. much easier to scroll through..
i did not know this before.. hindsight 2020
Good tutorial for installation of Unix on windows8.1?
what are you installing?
I vaguely recall there being an alternative for powershell..
There are some terminal emulators that use Git Bash to give you a Linux-like terminal on Windows
In Windows 10, you can use Windows Subsystem for Linux as well
Although that's basically a cmd-line only install of a distro, but it does give you the functionality you're probably looking for
Unless you're talking about installing a dual boot (linux/windows), then ignore everything I just said
windows 10 has the linux subsystem for windows thing where you can install ubuntu as a windows program and have access to a lot of nice tools
I wana make this script run a .py file
but its in a different directory
and I need it to be run in that directory
never used .sh files before so looking to learn something new
especially why shebangs exist
you can just cd /some/other/folder to change the working directory of your script
when Linux sees a file that is marked as executable, it looks at the first few bytes to determine the file type so that it knows what to do with it
the shebang looks like a valid comment to most script languages
but it tells Linux the path to the interpreter this script wants to be executed with
so if you have #!/bin/bash in my_script.sh, and run that script, Linux will execute the command /bin/bash my_script.sh
For Python, you'd usually use something like #!/usr/bin/env python3
which executes the /usr/bin/env command with python3 as first and your script path as second argument
it doesn't cd
just the absolute path to the interpreter executable
that's just where these executables normally are located
@oak shell but, why just the first folder that the executable is in?
why do you need it?
wdym first folder
it's the full absolute path to the interpreter
not sure if the absolute or relative path to the script is passed, probably whatever you entered to call it
What does the path represent?
is it like the path to the script
then why just the bin part?
and not any folder before it?
and by what I entered to call it, like what?
@oak shell
sorry this is confusing for me
I am probably just not getting it
/bin/bash is the full complete absolute path to the bash interpreter executable
so its so linux knows its bash?
if you call your script containing #!/bin/bash as ./foo.sh, it will probably execute the command /bin/bash ./foo.sh, if you call the script /home/lime/foo.sh it will run it as /bin/bash /home/lime/foo.sh, I assume
whatever there is after the #! will be used to construct a command that gets the actual script path appended as last argument, and then will be executed
so is it always /bin/bash for .sh files?
it is whatever you write
for Bash, you normally use /bin/bash, because on most Linux systems that is the absolute path where you would expect a bash interpreter
/bin/sh is also common for shell scripts that don't have bash-specific features
can also be e.g. /usr/bin/python
or everything, even your own interpreter, whatever that might do with the script it's supposed to run
oh waiiiiit
so like when you do python file.py
its the python part
so like its the same as
/bin/bash file.sh
is that what it is?
yes
I GET IT
AAA
thanks so much :D
so if I have this .sh file:
#!/bin/bash
cd ../src
git pull
python3.7 myfile.py
is that valid?
so it git pulls
gets latest data
and then runs myfile.py
yes, but it has flaws
im listening...
first, shouldn't it be python3?
then, .. will be relative to your current working directory, which is any arbitrary location
how would I write it?
my directory looks like this:
โโโ bin/
โ โโโ run.sh
โโโ src/
โ โโโ __init__.py
โ โโโ myfile.py
usually something like cd "$(dirname "$0")/../src" should work, I guess
$() is the subshell notation, so dirname "${0}" or $0 gets evaluated in the subshell, which then gets interpolated into the string. the 0'th parameter is the path it got invoked from including the script name.
im lost
hmm, that a bit simpler
Imagine you have a script like this
#!/bin/bash
echo "${0}"
if you call that, it prints
./script
if you have called it from the current directory that is (which it is in)
aka:
it already knows it's bash because of #!/bin/bash
ok
uhh
all I want to do
is have run.sh run
and that runs my python program
but I need it to be able to do so, also when called from anywhere
so like
if I call it from inside myfile.py
it should still run myfile.py
but also if I run normally
like inside its directory
two ways (*):
you find it, regardless of where you are
or
you use a hardcoded path, that does not change
or
you path the path as a variable
path the path?
hmm
what does that mean?
like send the path to the file?
how do I do that?
also question
if I run run.sh from anywhere, is the current directory where I ran it, or where run.sh is?
Stop confusing things:
your current path is determined by ${PWD} enviroment variable
The path your script is run is changing depending on what path you are calling it from
and the path of the argument, doesn't change at all, if you have one (that's not relative)
ok so the path used is the where you ran it from
gotcha
so uhh
${PWD} <- I am still confused on this
okay, sorry I didn't explain it
${} is basically the safe method of writing a shell variable
the contents of the brackets are the name of the variable
if on any unix/linux system you want to know which variables currently exist you can call set
pwd is shorthand for Pathname of current working directory
ok so then how do I somehow get my script to run correctly wherever I call it?
your first method is I find it wherever I am
how?
if you dont change the name of the script, you can use that as the searchkey
find . -type f -iname "scriptname" and use find to locate the script on the system
if you want a more cryptographic approach, you can embed a key in the file as a signature
hmm
why is it so hard just to make a sh file run regardless where you run it from
also how long will that find take?
Depends, if it's in the current directory it's quite fast (like not even a second)
but if you start from root, it can take quite long which is maybe not what you want
yeah lol
so you may rather want to look if the script exist in the path of the shell
which is the 'common' lookup path for shell-scripts
for example if I want to use my shell and run a script that I previously made
I dont put it somewhere randomly on my drive or the directory I started working on it
but I put it under /usr/local/bin/
my shell knows that this directory exists, and looks there first
oh I see
but its like
the full path
hmm that works
so I just change the directory to a full path
yes, that's one way
ok,
sorry, I find those things more intuitively
yeah
ok so I do like
if windows
(as an example)
cd C:something/somethingels/ssdf
sorta
but the thing is
that only works on one system
windows has bad and different shell support
yeah but the idea is cd the/full/path/of/a/folder
also is there a command that gets the directory that the shell script itself is in?
extra side note, can you do git pull anywhere inside of the directory? not just the root folder of it?
that not a full path, that is a relative one
yes current directory as implied is pwd, and yes but it depends on if a git repository exists in the current dir, which may not be the one you want to git pull for
wait pwd?
so like
ok here is what I want to do right now:
get the path of where the script is, using pwd(?)
so its like
no
pwd give you the path the shell is currently displaying (aka the directory you are in or something of that kind)
how do I get the path of where the script is then
your shell script however, that's still where it is. pwd is not a program to search something with
in the simplest, universal way possible?
oh I see
find / -type f -iname "script" for example
that uses pwd as the first place it checks?
and checks farther and farther away from it?
this algorithm starts from root
we are talking about two things.
one is the logic and smartness of the shell
the other is that you can start searching with find from a given directory like root
if you are intelligent you may want to use good pathes first
find /usr/local/bin/ -type f -iname "scriptname"
and then check if the result is [ -z "${value}" ]... but I'm not sure if you want to go that way
if you really just want to call it easily
like that's all but another can of worms
/usr/lib/llvm/7/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin for example those are the pathes you could look at "first"
ok but how can I make it work regardless of the system?
you do it in python and use os.walk
import os, fnmatch
def find(pattern, path):
result = []
for root, dirs, files in os.walk(path):
for name in files:
if fnmatch.fnmatch(name, pattern):
result.append(os.path.join(root, name))
return result
find('*.txt', '/path/to/dir')
can you explain what is going on?
give me a second, i will be right back
ok
So this is a function that finds a file, given a pattern and a directory from which to start
and then is recursively 'walks' through the filesystem to look for that pattern, basically
well depends on how you want to do things. You wanted to make it system independent, so you may not have pwd as you like it
the current directory you called something from is also different in python os.getcwd() vs bash pwd
I want a simple, system independent way, to get the path of where the script lies as fast as possible
I mean nothing hinders you from looking in the current directory first, but if it doesn't return the value you expect, then you have to check other directories too
and from a heuristical standpoint, each directory is differently likely to hold your script depending on the OS
how about this
can I force it to run only if it is run in the same directory?
but at the same time
can I somehow make python run script.sh but change directory first?
like make python run it, at its directory
yes or you can only run it if you give it it's paired script name as a parameter
if you know where it is, you can os.chdir() to it and call it. If you don't you have to find it first
wait so chdir, how does that work?
or lemme rephrase that
os.chdir("./bin") changes WHICH directory, to the bin folder
...
os.chdir("../bin") does change the current directory to it's parent directory, and then that parent's bin directory, if that exist
that is not the same as /bin/
cuz im so confused, you have the current directory, the then you have the path your script is run
./bin, is the current directory,
so like
I show you then
sorry ๐ฌ Thanks for not giving up yet...
oh yeah I know .. moves to the parent directory
in my shell [test] display my current directory
just the way I described it was odd
so I just made it simpler and edited it
so for my .sh file
can I use the info on where the script was run from, and then check if that path has script.sh, if so, you called it in the same directory, else, close
like pwd
you probably dont have the info of where the script was run from
or do you mean from the shell?
uhh
idk anymore
you said like
pwd
I thought that was the info on where the script was run from
Sorry, I was just making sure the context was right. For example if you have a certain chain of events, the information may get lost.
ok...
so what do you know then?
also what do you mean by .sh files have parameters?
okay
If you have a shell script as I said earlier, ${0} is a parameter that contains the path the script is called from including it's name
if you path a second parameter like it would be denoted by ${1}, you can read that too
in python, depending on how complex you want to get, you have argparse or argv
wait so there a scripts and there are shell scripts?
is .sh a shell script or a script?
no
It would confuse you more then it should. I mean python is technically not a shellscript, but maybe in some cases if it's called from a shell.
so anyway that's stupid
I'm not quite sure, but do you want to call both ways, aka: python scripts calls shell script and shell script calls python script? So far, I assumed you wanted to use the python script to locate the shell script and call it.
Nonono
I have a python file, and in it, I want to call to this .sh file
But I need to call it to the .sh file while ensuring the the current directory is the same as where the .sh file is
give me a second, I have one other task, but then I can give you working code example of what you want
And some way to have the .sh file only run if the current directory is in the same place as the .sh file
Oh that would be helpful to study, thanks!
Is this where I ask a probably simple linux question?
you want to run a python script using an sh script?
do you want to pass arguments using the sh script too?
@plain bramble thanks for helping me btw, will you be able to have time to explain the working code snippet?
It's ok if you can't, ill just try on my own
I will take a while I guess, so you can start at subprocess in python if you want
Cuz like all the stuff done in python is os.chdir and then sp.run script
The next thing is figuring out how to get my script to only run when it is in the same directory as itself
Sort of like python's if name in main
The rest are just simple commands that I hope don't need anything
And I need to exit out of my python program at the end too
I have a question about zipping and unzipping files. On a server at work, we have a directory /pos/apps/ and in here are a few shell scripts example1.sh and example2.sh. These shell scripts are then zipped up and placed on remote pc's in different directories such as /home/user/bin/example1.sh /opt/environment/example2.sh. We unzip them using unzip -o: example.zip. My question is, how do you specify the path the files will go to once unzipped?
@plain bramble sorry to bother you again but
An optional directory to which to extract files. By default, all files and subdirectories are recreated in the current directory; the -d option allows extraction in an arbitrary directory (always assuming one has permission to write to the directory). This option need not appear at the end of the command line; it is also accepted before the zipfile specification (with the normal options), immeโ
diately after the zipfile specification, or between the file(s) and the -x option. The option and directory may be concatenated without any white space between them, but note that this may cause normal shell behavior to be suppressed. In particular, ``-d ~'' (tilde) is expanded by Unix C shells into the name of the user's home directory, but ``-d~'' is treated as a literal subdirectory ``~'' of
the current directory.```
@raven kernel
import sys
sys.exit()
Thanks @plain bramble. That will definitely lead me in the right direction. I will look into this option more. Thanks again.
@main olive did you make any progress?
@plain bramble no, not really, I think I have figured out everything except only running when it is at the right directory, also you forgot to give me a code snippit.
my .sh file looks like this:
#!/bin/bash
cd ../src
git pull
python3.7 mybot.py

@plain bramble are you there to help me?
@main olive
Not beautiful, but maybe just to find your script in a few common locations on linux/unix (as you are using bash)
$(echo "${PATH}" | sed "s/:/\n/g" | xargs -I % bash -c 'find "%" -mindepth 1 -maxdepth 1 -type f -iname "script" -print -quit 2> /dev/zero' | head -n1)
you could then assign that value to a variable by
scriptname = $(...
and run you script by python
python3.7 "${scriptname}"
@main olive you may also want to change the python version you call to run you script
by adding the shebang in your python script and just call it from bash aka ./script
the shebang would look like
#!/usr/bin/env python
if you want to run python from the enviroment variable but there are other way you can ensure only certain versions of python are run, if that's what you need
is it possible to run lisp from shell..
I'm trying to convert an expression to csv.. found cl-csv in lisp.. exhausted all my options at this point
it's an s-expression I've been trying to handle with pyparsing.. but can't seem to get around it
can you explain further? @main olive
I have this weird s-expression .. nested within it are expressions that point to how sentences will be parsed... and sentences as well along with reference ids..
need a way to parse it and put it in a csv.. I can do it with regex, but I'm looking for something concrete
I tried sexpdata module.. it works.. a little bit.. If I can build off of that, it'd be cool..
because sexpdata recognizes comment lines # as part of the expression
rosettacode has an s-expressions parser too, how does that differ from your use case? https://rosettacode.org/wiki/S-Expressions#Python
let me try this
this is similar to sexpdata.. I think I'll stick with sexpdata.. or try to rewrite it to suit my purpose..
because sexpdata is able to isolate symbols.. so I could use that as a reference field.. and see how much it is populated..
I have ubuntu 10.10
A really old server
And there is nothing in the user directory
So I canโt run Sudo, apt, su, passwd, etc.
Can I just install the latest Linux?
Will it fix my issues?
Ok it has su
wdym nothing in the user directory? /usr or /home ?
and yes, 10.10 is ancient and out of support for roughly eight years. IMO it's not even worth upgrading that system, especially if some things are potentially broken already. Back up all data and do a fresh install of the latest LTS release, i.e. 18.04
idk to what. whatever you have available. usb drive maybe? I don't even know if there is anything useful on the machine at all that's worth to be saved.
if the install is as broken as it seems to be, you might have to boot from a live system to be able to mount external drives and copy stuff over anyway
back when ubuntu 10.x was popular people recommended separating your main file system folders out to different partitions
its possible that someone physically removed the harddrive that contained /usr
just installing a modern linux distro will work, assuming the hardware is fine
My grandfather gave it to me
It was from 2003
Guess what is on here XD
Itโs a really outdated version of wireshark
Called wireshark
I think they were programming it
Ima back it up and then upgrade this b
Hello. I know this isnt Python but im lost.
I have my main PC that has built in Wifi Connectivity and an ethernet port. I then have a PC that has ethernet and no Wifi Connectors. So, Via Windows 10 I bridged the Wifi and Ethernet on my main pc and hooked it into the server.
When I do ifconfig it shows it shows the IPv4 as the same as my PC, But isnt getting any internet connection
any ideas?
did you enable dhcp on the computer that has to use the ethernet connection?
I dont think so. Ill try
generally a bridge will let devices connected to the ethernet port act like they are on your wifi network. so you should be able to just enable dhcp to get an ip address and then it should route correctly by itself
it worked. Thankyou very much
@grave jolt Hey can you help me make a bootable flash drive?
i dont know if i need a special ubuntu for a server
im pretty confused
@oak shell maybe you can help?
with a computer of that age you should be able to just make a regular bootable one with the tools available on the ubuntu website.
for a server you can run whatever, the only difference between versions is what user software is installed.
server ubuntu doesnt include a desktop environment.
desktop ubuntu generally includes a gui and everything a normal user would want like office software
you can install a gui later if you decide you want one
how do i just install the command line one
you go to ubuntus website, download the ubuntu server iso, then use a tool like rufus or whatever they recommend to write the iso to the usb drive
you dont just copy the file as like ubuntu18.whatever.iso
you have to use a tool to write the contents of an iso to your usb drive
will it accidentally install on the computer i am using to write it?
you would have to go out of your way to mess up and do that. generally they wont even list your main hard drive
it should only list removable drives and windows will likely refuse to let you write to the main hdd while booted
but if you have multiple usb drives plugged in you could end up overwriting the wrong one
can we hop in a call so you can assist me?
cant atm sorry
im gonna screw up
you might fail if you try, but you already failed if you just give up
just take a deep breath, read each step and then do what it said. it includes pictures of each step
this is for the command line only one?
it will install whatever version you download. in step 2 you choose which version to download, if you click the link they provide the second download is 'ubuntu server'
so lts is 'long term support' ubuntu releases a new version every 6 months or so. if you want to be able stay on the same version for 5 years and still get security updates choose lts
that might be too small
i can upgrade while keeping data?
yes
ubuntu 18.10 server is only 881MB, there is a chance it will fit on your 1GB usb drive
i just got a 4gb
sorry. But im back again after a few hours. I got the Bridge working and the Ubuntu server is actually connected to the internet. Issue is that it shares the same IP with the main PC that its connected to. Would it be possible to give it a new local IP to an unused one like 192.168.0.???
if the network is actually bridged, the server should get its own IP by your local router's DHCP. If it has the same IP as the machine you use to share the internet connection, that means it is NAT and not a bridge.
crap then. Does that mean no way to change it?
it should be possible, but I haven't done that yet. not sure how exactly it works
@grave jolt what do i do after i wrote the usb?
also how can i un-write the iso file after im done with it
put the usb drive in your computer that you want to install ubuntu on. reboot that computer and go in to the bios and set it to boot from your usb drive. how to do this varies by manufacturer.
then when it restarts again it should boot ubuntu and you can follow the on screen menus to install it
do i want the computer on
to fix your usb drive back to a normal one you can use windows to reformat it
wait wait hold on
it doesnt matter for usb. you have to reboot in to the bios so you can start with it off then boot it, or just hit restart
what was that first thing you said
what do you mean
riffautaeToday at 3:32 PM
put the usb drive in your computer that you want to install ubuntu on. reboot that computer and go in to the bios and set it to boot from your usb drive. how to do this varies by manufacturer.
then when it restarts again it should boot ubuntu and you can follow the on screen menus to install it
thats so confusing
can you make it like a list or something
1: put the usb drive in to the computer
2: reboot the computer
3: while its rebooting look at the screen and figure out what key its telling you to press to get in to the bios. usually del or f12
4: go in to the bios, find the boot sequence, change it so that the usb drive is first
5: save and restart
6: ubuntu will boot
do i want the computer on
when i start it
the beginning of the list
do i want it on or off
it doesnt matter
k so i start with it off
at step 2 your reboot it or turn it on if its off
if i plug the usb into my windows laptop again will it screw up my laptop?
when i wanna make it a usb again
no, you would have to go through a ton of obvious steps to install ubuntu so you cant do it accedentally and mess up your laptop
ok so im plugging the usb in now
now turn on the computer?
@grave jolt
Yo help
Cmon man donโt leave me hanging
God damnet itโs frozen
Dude!
Idk what to do
looks like your usb is before the internal sata hdd in boot order, that's good
it should just boot from the USB instead of the disk if you start the computer with the stick plugged in
K
Now I run startup?
Or do I restart computer
Oh itโs auto restarting
Itโs still 10.10!!!!
It didnโt work
Iโm restarting
@oak shell
Itโs not working
All the same servers
I thing worked
Nothing
on the BIOS POST screen, can you press some key to get a boot device menu (not the BIOS setup menu)? Maybe F9 or something like that
nope, sorry
I hit f9
Idk what is happening
Great itโs trying to start up again
Amazing
@oak shell
can you just remove the hdd from the boot order completely instead?
in the boot device priority or the hard disk devices on the screen you showed last, I guess
can you change the SATA one to Disabled or anything else that removes it from the list?
I see, then go back and into the hard disk drives submenu instead
probably you can disable it there
there's three of them? ๐
What
all these SATA entries seem to be internal hard disks
internal enough
can you select each of them and disable it? only leave the USBs enabled in the menu
Those are storage no?
yes, these are removable disks in the photo
oh, so that menu is just for changing order too
Yea
yeah, then make sure the USBs are before the SATAs
Do I exit this menu or put both subs first
Ok
Ima run the thing again now
One purpley boi
it would be good, that way it can directly install updates, set the correct time, etc
The server wonโt start
I lost power halfway into installation
It wonโt start up again
@oak shell
Yo!
Help please
Dude
My thing is broken
Come on
what do you mean it won't start?
It wonโt start
I turn it on
And it doesnโt do shit except blink colors on the box
if you lost power during the installation, you will have to redo the whole installation process, I assume
no BIOS POST screen?
No
then it's dead
And the few times I get one, it is frozen and doesnโt do anything
What do you people say about devuan not debian or antix and arch or black arch?
Hey!
Whats your opinion on these Linux distributions?
This thing is around 600 dollars
Well, if the BIOS POST doesn't even show up, either some core hardware broke or the firmware got damaged
Okay nvm
You can try disconnect all power for a while, in case any static has built up somewhere maybe, and you could try replugging all components
Could it not have enough power?
I moved it to a surge protector
InsteD of the one I was using
I'm not sure. Possibly, if the power supply changed compared to earlier. Does it reliably turn on if you switch back?
๐คท
leave it completely disconnected from power for a couple minutes, replug all hardware components maybe, dunno
What is that thing that keeps turning red
idk what you mean
In the video
Look at the video
The only other thing that could be the issue is the fact that I plugged in Ethernet
the led above your finger when you turn it on? It's too blurry, I don't see what that is.
that is a Hard Disk symbol
no idea what that LED being red means. maybe
a power cut can potentially destroy disk drives
maybe try to find the manual of your server to learn what the LEDs mean
I only have the server
but even if the disks died, the system should still POST and get into the BIOS settings menu reliably at least
No manuals
google online for the exact model name
can't help you there either then
Should I take out the drives and blow on them
nothing as in still no reliable display, same as with them?
then it's probably not those
if its from 2003 its possible that it has finally died. check the power supplies and listen for beeps and stuff. if you can go online and download the manual and see what all the lights and beeps mean
also most servers from 2003 are not expensive. you can get something like an r710 which was released in 2009 for like 200 bucks. one from 2003 is not going to be worth more if its just a normal server
it has an intel core sticker on it, that means its from like 2006 or newer since those processors didnt exist before then
i checked for a bios error
the memory osculators arent connecting
i am going to take them to be cleaned
ok
the flat server above is a windows server
it is from 2003
it is supposed to manage traffic or something
i fixed it but ty @vagrant rune
what'd you do? @upbeat peak
i ended up using wget and then getting 3..6.4 from the source, then building it etc
it was a bit of a long process lol
yeah
Why does the python3 shell make a beeping noise loud enough to alert extraterrestial life of my presence whenever I backspace with no input present, even though I muted every single one of my audio devices, and how can I stop it doing that?
i believe the beep is called "terminal bell". not sure how to disable it though...
I mean, surely, it would be muted if I muted all my audio devices, right?
But then again - linux
I mean, you'd expect a system sound to go through the system audio devices and not directly through the f-ing motherboard or whatever
๐
But yeah, ifixedit
what does reboot time depend on
how many services have to be killed, if you can load the system from a fast or slow disk. And so on
Like how many services you have to start before the system runs
How much time are we talking about and what system?
For my system for example, shutdown time can take as long as the watchdogs dying but start up is fast
lemme see.. it's a Debian Rodete.. 8 core machine.. feels like it takes forever to reboot
5minutes
the ssh service takes a bit
until for example systemd starts it
you can also look at the targets, which are run first
like.. from the bashrc?
bashrc is quite high level