Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Apex Rogers
Jun 12, 2006

disturbingly functional

F_Shit_Fitzgerald posted:

I'm writing a script that uses grep in a while-loop. Is there a way to get grep to shut the gently caress up so that I don't have to see the

Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.

message every time I run the script? The -s flag doesn't seem to work.

Yeah, that only prints if you’ve invoked grep incorrectly. What you have now is not doing the grep you think it’s doing, or anything at all.

Adbot
ADBOT LOVES YOU

F_Shit_Fitzgerald
Feb 2, 2017



AlexDeGruven posted:

Sounds like your grep is failing. What's the line you're trying to run?

Admittedly, it's probably not the most elegant way to do this:

offs=`echo $alpha | grep -obs $letter | tr -cd '0-9'`

Where
alpha is an alphabet string
letter is a letter extracted from a string

So what this is supposed to do is search for a letter in the alphabet string and use its position (e.g: a=0, b=1, etc) to modify a position in an array corresponding to a letter (so position 0 is a, position 25 is z, etc).

No, it's not homework. This is a script for my own system.

F_Shit_Fitzgerald fucked around with this message at 00:07 on Mar 20, 2023

Saukkis
May 16, 2003

Unless I'm on the inside curve pointing straight at oncoming traffic the high beams stay on and I laugh at your puny protest flashes.
I am Most Important Man. Most Important Man in the World.
My guess is for some reason $letter is empty.

kujeger
Feb 19, 2004

OH YES HA HA
This is pretty much always worth doing for bash scripts:

http://redsymbol.net/articles/unofficial-bash-strict-mode/

Phosphine
May 30, 2011

WHY, JUDY?! WHY?!
🤰🐰🆚🥪🦊
I also highly recommend shellcheck for any script whose correctness and maintainability you care about. It's been a lifesaver many times for me.

F_Shit_Fitzgerald
Feb 2, 2017



e: Never mind; I fixed the problem. I was taking the length of a string and then running through a while-loop to extract each letter, but the length was exceeding the actual length of the string. In other words, Bash is similar to something like C++/Java where there's a terminal character at the end of chars. It was reading that null string and complaining because it wasn't legitimate input to grep.

F_Shit_Fitzgerald fucked around with this message at 14:28 on Mar 20, 2023

spiritual bypass
Feb 19, 2008

Grimey Drawer
For a couple weeks, I'd suffered from my ssd taking 20 seconds or more to go from Grub to starting the Linux kernel. In the past, it would take me from bootloader to login prompt in only a couple seconds. Dmesg showed an error I can't remember about something with my disk, so I decided the disk was failing and bought a replacement. By the time my replacement arrived, Linux stopped booting entirely. I could still use Grub from the same disk's EFI partition to boot my Windows disk, but Linux just wouldn't work.

From a live USB, I mounted my old OS disk, partitioned/formatted the new disk with EFI and OS partitions, copied the data from both partitions (rsync) to the new disk, rewrote my fstab and Grub config to use the new disk, and updated my EFI boot menu. It strikes me that both disks worked fine during the copy process.
With the new disk in place and the old one removed, I get the exact same behavior. The Grub menu comes up fine, I can boot the Windows disk without issue from Grub, but it freezes without error when I try to load Linux. To be sure, I've also tried loading the current LTS kernel and also loading from the Grub CLI instead of the menu. Same behavior. No messages, quiet mode off. The kernels and initrds live on the EFI partition.

Is my SATA controller failing? It's hard for me to think so since I've switched the ports for the Windows and Linux disks in the midst of the disk replacement. I'd hate to just throw new hardware at the problem blindly, although my CPU is getting a little old.

What else can I try? How can I be sure of the source of the problem?

cruft
Oct 25, 2007

I would blow Dane Cook posted:

How do you make the fonts not look like poo poo in chrome on arch?

This is a vague question. What looks lovely about them?

I'm going to hazard a guess that you're using Wayland on a HiDPI monitor and you haven't told Chrome to use Wayland output. This is making it draw fonts at like 72DPI or whatever, and then Wayland scales them up to the 280DPI of your monitor or whatever, and then it's all fuzzy.

Solution: tell Chrome to use Wayland. It's in flags somewhere. Be aware that you'll lose the ability to do screen sharing if you do this: you can only share Chrome tabs. Or at least that was the case back when I was still using Chrome.

ExcessBLarg!
Sep 1, 2001

kujeger posted:

This is pretty much always worth doing for bash scripts:

http://redsymbol.net/articles/unofficial-bash-strict-mode/
I'm thinking, "This looks pretty good, but why the IFS stuff? Just quote the array variable in the for loop." Then I see the explanation:

Bash Strict Mode posted:

Another approach: instead of altering IFS, begin the loop with for arg in "$@" - double quoting the iteration variable. This changes loop semantics to produces the nicer behavior, and even handles a few edge cases better. The big problem is maintainability. It's easy for even experienced developers to forget to put in the double quotes. Even if the original author has managed to impeccably ingrain the habit, it's foolish to expect that all future maintainers will. In short, relying on quotes has a high risk of introducing subtle time-bomb bugs. Setting IFS renders this impossible.
Yeah so this works fine until you encounter something like a file name with a tab in it. Sounds perverse, but using "${files[@]}" in your loop is always correct.

kujeger
Feb 19, 2004

OH YES HA HA
Tbh ive never done the IFS bit either

spiritual bypass
Feb 19, 2008

Grimey Drawer

cum jabbar posted:

For a couple weeks, I'd suffered from my ssd taking 20 seconds or more to go from Grub to starting the Linux kernel. In the past, it would take me from bootloader to login prompt in only a couple seconds. Dmesg showed an error I can't remember about something with my disk, so I decided the disk was failing and bought a replacement. By the time my replacement arrived, Linux stopped booting entirely. I could still use Grub from the same disk's EFI partition to boot my Windows disk, but Linux just wouldn't work.

From a live USB, I mounted my old OS disk, partitioned/formatted the new disk with EFI and OS partitions, copied the data from both partitions (rsync) to the new disk, rewrote my fstab and Grub config to use the new disk, and updated my EFI boot menu. It strikes me that both disks worked fine during the copy process.
With the new disk in place and the old one removed, I get the exact same behavior. The Grub menu comes up fine, I can boot the Windows disk without issue from Grub, but it freezes without error when I try to load Linux. To be sure, I've also tried loading the current LTS kernel and also loading from the Grub CLI instead of the menu. Same behavior. No messages, quiet mode off. The kernels and initrds live on the EFI partition.

Is my SATA controller failing? It's hard for me to think so since I've switched the ports for the Windows and Linux disks in the midst of the disk replacement. I'd hate to just throw new hardware at the problem blindly, although my CPU is getting a little old.

What else can I try? How can I be sure of the source of the problem?

Tried a clean reinstall on the new disk. New rootfs and new EFI system partition with no old data. Still getting stuck when loading the most recent and LTS kernels. No smart errors on the disk and no memory errors from memtest. Boots fine from the live USB and Windows still works fine, too. Totally baffling. Guess I'm going in for a new motherboard, although this AM5 stuff seems kinda overpriced.

Nitrousoxide
May 30, 2011

do not buy a oneplus phone



You have anything like fastboot toggled/untoggled on your bios settings? You might just have some mobo setting toggle to wait to let you switch your boot device, or you might have a boot device plugged in that it's running through first, not finding a way to start and then switching to a secondary boot device.

Klyith
Aug 3, 2007

GBS Pledge Week

cum jabbar posted:

Totally baffling.
edit: missed info

spiritual bypass
Feb 19, 2008

Grimey Drawer
No, I have fast boot turned off. The builtin boot menu selects my Linux, Windows, or live USB disk without issue. It's just that I can't get past Grub on my Linux disk. Grub also works fine chainloading to Windows. Also tried installing systemd-boot but it behaves the same way, hanging before initrd. I can't even get to initrd rescue mode. The actual initrd looks sane when I peek at the filesystem.

Just did a full memtest and came out clean. The live USB has the same kernel as my SSD, so no discrepancy there.

VictualSquid
Feb 29, 2012

Gently enveloping the target with indiscriminate love.
Did you try a non-grub bootloader for the linux? Not sure what is around these days. I would also check a few different versions of Grub before buying new hardware.

Klyith
Aug 3, 2007

GBS Pledge Week
Which memtest are you using, the open source 86+ or the commercial memtest86.com one? The commercial one is, frankly, much better.

spiritual bypass
Feb 19, 2008

Grimey Drawer

VictualSquid posted:

Did you try a non-grub bootloader for the linux? Not sure what is around these days. I would also check a few different versions of Grub before buying new hardware.

Tried systemd-boot. Same behavior, unfortunately.

Klyith posted:

Which memtest are you using, the open source 86+ or the commercial memtest86.com one? The commercial one is, frankly, much better.

The open source version.

zhar
May 3, 2019

i decided on the unconventional Fedora and i3 spin for my 2023 linux adventure. i figured out i dont want tiling so much as hotkeyed fullscreen window swapping. can kind of do this on windows by hotkeying taskbar groups but was never able to get multiple ff profiles working. no doubt easy to get working on any linux de but i want to start with something simple.

overall ill give the installation experience 3/5 and will only be recommending installing Fedora to those with more capable hands than myself.

antimalware service got fixed on win with an engine update but there's still something strange going on with ff my gpu is more active browsing text pages alongside desktop window manager than when decoding a video and i dont like it. still stuck on it for the moment though as there's a fair bit of config left to do on linux. maybe firefox is the problem its a shame the only real alternative is some brand of chrome.

ExcessBLarg!
Sep 1, 2001

cum jabbar posted:

Totally baffling.
Not sure what distribution you're running (or I missed it) but if it's using GRUB+Shim I would disable secure boot and install plain grub (not the shim/signed version).

I've run into a bunch of weird issues with GRUB+Shim with secure boot both on and off, and this kind of sounds like what I've seen before.

I would blow Dane Cook
Dec 26, 2008
Best way to browse something awful forums in the terminal?

Yaoi Gagarin
Feb 20, 2014

I would blow Dane Cook posted:

Best way to browse something awful forums in the terminal?

lynx

BlankSystemDaemon
Mar 13, 2009



I would blow Dane Cook posted:

Best way to browse something awful forums in the terminal?
w3m, because it has image support and renders containers properly

spiritual bypass
Feb 19, 2008

Grimey Drawer

ExcessBLarg! posted:

Not sure what distribution you're running (or I missed it) but if it's using GRUB+Shim I would disable secure boot and install plain grub (not the shim/signed version).

I've run into a bunch of weird issues with GRUB+Shim with secure boot both on and off, and this kind of sounds like what I've seen before.

It's Arch with plain Grub 2, no secure boot. Good to know about the shim thing, though.

zhar
May 3, 2019

last few days spent configuring linux while listening to hyperpop :cheers:

do not wish to ask too many questions imo got to have a diy attitude and grit to survive and thrive in the world of linux but i have one. as its too annoying to reboot each time something changes to see if it works. when i installed nvidia drivers luks unlock screen switched to crt resolution therefore, how do i get hd resolution back? i tried video=2560x1440 kernel parameter but no luck. also been reading about command GRUB_GFXMODE but this is for grub and i think luks screen is something called plymouth? if it is this i put in default/grub do i need to rebuild grub or is this something i should be editing with grubby or is grubby just for kernel parameters and this is a grub parameter? im not conviced this is it anyway why would the nvidia driver remove this?

i must say nvidia seems at odds with this os so much time chasing problems down a rabbit hole to find nvidia propietary driver(can't fix) at the bottom also the terminal emulator fan community is nuts

Tacos Al Pastor
Jun 20, 2003

Does anyone know of a way to stop the script command from logging terminal output? I have a hung process and it seems outside that window I cant simply type "exit" to get script to end. Would like to know of an alternate way to get script to end and write to the file.

cruft
Oct 25, 2007

Tacos Al Pastor posted:

Does anyone know of a way to stop the script command from logging terminal output? I have a hung process and it seems outside that window I cant simply type "exit" to get script to end. Would like to know of an alternate way to get script to end and write to the file.

did you try kill -1?

Mr. Crow
May 22, 2008

Snap City mayor for life

zhar posted:

last few days spent configuring linux while listening to hyperpop :cheers:

do not wish to ask too many questions imo got to have a diy attitude and grit to survive and thrive in the world of linux but i have one. as its too annoying to reboot each time something changes to see if it works. when i installed nvidia drivers luks unlock screen switched to crt resolution therefore, how do i get hd resolution back? i tried video=2560x1440 kernel parameter but no luck. also been reading about command GRUB_GFXMODE but this is for grub and i think luks screen is something called plymouth? if it is this i put in default/grub do i need to rebuild grub or is this something i should be editing with grubby or is grubby just for kernel parameters and this is a grub parameter? im not conviced this is it anyway why would the nvidia driver remove this?

i must say nvidia seems at odds with this os so much time chasing problems down a rabbit hole to find nvidia propietary driver(can't fix) at the bottom also the terminal emulator fan community is nuts

You mentioned Fedora before (the correct choice), if so delete everything you've done and do this https://rpmfusion.org/Howto/NVIDIA?highlight=%28%5CbCategoryHowto%5Cb%29

Its basically add rpm-fusion repos and sudo dnf install akmod-nvidia

Rpmfusion is the official "unofficial" repo for packages that cant be in the main repos due to licensing

Then nvidia should just work, sudo nvidia-settings if you need to mess with display settings

You may need to blacklist the default open source nvidia driver so the kernel doesn't try and load it too, check arch wiki if the rpmfusion page doesn't go over it, nouveau is the open source driver name

Im on amd these days so posting from memory

Mr. Crow fucked around with this message at 22:58 on Mar 23, 2023

ziasquinn
Jan 1, 2006

Fallen Rib
I always install pop shell for its magnificent tiling extension/feature whenever i install arch. its god's way.

although i liked material shell, it was relatively buggy, have to disable/re-enable it more often than I'd like.


Tacos Al Pastor
Jun 20, 2003

cruft posted:

did you try kill -1?

I did not, I was hoping that by not killing it it would still capture what was causing the process hang. I guess script doesnt do that though.

tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe
I downloaded avahi on my Debian box I use to host a bunch of home server stuff because I got tired of the smb shares not showing up in my Finder sidebars. However, even though my hostname is "server", avahi seems to be advertising it as "SERVER". Is there any way to control that? The name is correct in avahi's config files. Sorry if this is a MacOS question instead!

In the image below, kacynas and nas are both Synology Diskstations and labrys is a MacBook Air with a smb share. One of these things is not like the others and it's vaguely annoying because I mostly want to know why.

Only registered members can see post attachments!

VictualSquid
Feb 29, 2012

Gently enveloping the target with indiscriminate love.
It probably is in compatibility mode for some old smb version that doesn't respect capitalisation.

zhar
May 3, 2019

Mr. Crow posted:

You mentioned Fedora before (the correct choice), if so delete everything you've done and do this https://rpmfusion.org/Howto/NVIDIA?highlight=%28%5CbCategoryHowto%5Cb%29

Its basically add rpm-fusion repos and sudo dnf install akmod-nvidia

Rpmfusion is the official "unofficial" repo for packages that cant be in the main repos due to licensing

Then nvidia should just work, sudo nvidia-settings if you need to mess with display settings

You may need to blacklist the default open source nvidia driver so the kernel doesn't try and load it too, check arch wiki if the rpmfusion page doesn't go over it, nouveau is the open source driver name

Im on amd these days so posting from memory

no i did that the the other things im referring to i genuinely can't reasonably fix. thanks for replying though. for this issue in particular i was correct about video=, it needed to be video=efifb:mode=0 (which = 2560x1440) instead of 2560x1440. as for the others just seems like an issue every step.

when i was looking at desktop environments and window managers i looked at some of the wayland ones. seems to be stability issues all over the place with nvidia! probably fine if you use gnome. gnome is not for me. issue about one on nvidia open source kernel driver github opened a year ago, nvidia guy immediately says thanks and triaged. no updates since. x11 for me.

i didnt like the menubar on the default terminal, so i looked up what people are using and the names alacritty and kitty came up. this is where i discover how strongly people feel about terminal emulators. i choose alactritty because i dont think i need fancy features of kitty. some time later i call mpv from the terminal to play a video, and notice when i fast forward (x2 speed etc) alacritty uses 100% of a cpu core. at first idk if this is a mpv issue, linux issue, terminal issue or this is expected behaviour when calling from terminal. i narrow it down to dropped frames which displays a value in terminal and increases very fast with higher playback speed. it only happens on alacritty terminal, no other terminal is effected. no issues about this in particular in mpv or alacritty repos, but im able to find a few similar issues in alacritty github. first one i look at alacritty dev smugly says that his terminal is too fast, he isnt going to bottleneck operations like other terminal emulators and op should submit an issue to program dev to send output less often. next one i look at the op has done some perf analysis or something and turns out nvidia propietary driver is causing the issue. alacritty dev says he doesn't know whats going on in closed source driver and won't fix. now im using kitty. do i even need a gfx card powered terminal? probably not. interested if anyone here uses any of the fancy features and if so which ones?

next up, im setting up firefox. its possible to get hw accelerated video with a few tweaks. one of these is disabling the rdd sandbox so i look up what this means as it sounds a little sketchy (i think you only need to do it on nvidia cards). eventually i figure out it probably isnt the worst thing, however in the process i stumble upon an issue in the nvidia-vaapi github that explains that nvdec loads cuda which forces the card into a higher power state for no reason, negating most of my personal reasons to use hw accel in the first place. "It's been brought up before [with nvidia] and we've never seen anything get done" he says. i don't bother using it in the end.

im going to stop now but ive concluded that linux desktop is at the bottom of nvidias priority list and open source people are often ideologically opposed to supporting nvidia hardware. feels im caught in the middle of an abusive relationship. too much time wasted on these issues.

anyways, another question: i want to run a program on wake from suspend, i decided to use the /usr/lib/systemd/system-sleep method (like so) with a hacky "sudo -u me program" to get it to run as me. what is the advantage of using a proper systemd service? and should i pipe the output anywhere as best practice?

spiritual bypass
Feb 19, 2008

Grimey Drawer
Getting a new motherboard and running grub-install got everything back to normal. No idea why the exact same thing wouldn't get results on the old motherboard :shrug:

Mr. Crow
May 22, 2008

Snap City mayor for life

zhar posted:

anyways, another question: i want to run a program on wake from suspend, i decided to use the /usr/lib/systemd/system-sleep method (like so) with a hacky "sudo -u me program" to get it to run as me. what is the advantage of using a proper systemd service? and should i pipe the output anywhere as best practice?

You can use runuser or runas in your script instead of sudo since it's (probably) being run as root anyway. I'm not familiar with that interface so I'm not sure if systemd will capture the output of those scripts or not, but you can make a unit file that does the same thing https://unix.stackexchange.com/questions/152039/how-to-run-a-user-script-after-systemd-wakeup#492497 which would output to journald which has all the usual logging settings (e.g. you can ship it to a central logger if you want or just use journalctl).

If its already running and working to your satisfaction under the shell script you dont need to mess with it. There doesn't seem to be any particular advantage to one method vs the other except maybe more standardized ux via systemctl and journalctl, if you want to use all the other features systemd has then i guess that would be a + in its favor but i'm assuming your just setting a config value or three somewhere so /shrug. Probably doesnt matter if you need private temp directories or resource controls.

tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe

VictualSquid posted:

It probably is in compatibility mode for some old smb version that doesn't respect capitalisation.

Do you know which parameter would control that? Looking through avahi-daemon.conf I toggled some stuff that sounds helpful, but it didn't fix the issue. Here's my config file:

code:
[server]
host-name=server
#domain-name=local
#browse-domains=0pointer.de, zeroconf.org
use-ipv4=yes
use-ipv6=yes
#allow-interfaces=eth0
#deny-interfaces=eth1
#check-response-ttl=no
#use-iff-running=no
#enable-dbus=yes
#disallow-other-stacks=no
#allow-point-to-point=no
#cache-entries-max=4096
#clients-max=4096
#objects-per-client-max=1024
#entries-per-entry-group-max=32
ratelimit-interval-usec=1000000
ratelimit-burst=1000

[wide-area]
enable-wide-area=yes

[publish]
#disable-publishing=no
#disable-user-service-publishing=no
#add-service-cookie=no
#publish-addresses=yes
publish-hinfo=yes
publish-workstation=yes
#publish-domain=yes
#publish-dns-servers=192.168.50.1, 192.168.50.2
#publish-resolv-conf-dns-servers=yes
#publish-aaaa-on-ipv4=yes
#publish-a-on-ipv6=no

[reflector]
#enable-reflector=no
#reflect-ipv=no
#reflect-filters=_airplay._tcp.local,_raop._tcp.local

[rlimits]
#rlimit-as=
#rlimit-core=0
#rlimit-data=8388608
#rlimit-fsize=0
#rlimit-nofile=768
#rlimit-stack=8388608
#rlimit-nproc=3

Klyith
Aug 3, 2007

GBS Pledge Week
What about smb.conf?

quote:

Support for lower casing the MDNS Name
--------------------------------------

Allows the server name that is advertised through MDNS to be set to the
hostname rather than the Samba NETBIOS name. This allows an administrator
to make Samba registered MDNS records match the case of the hostname
rather than being in all capitals.

This can be set with the following settings:

'mdns name = mdns'

The default is to use the netbios name, which itself defaults to your hostname in ALLCAPS.

waffle iron
Jan 16, 2004
It looks like it's in the Samba config.

https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html#idm6797

tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe
Thanks for pointing that out! I tried just adding "mdns name = server" under [global] and got a systemctl error. Testparm says that it won't work. Is there a specific section this has to go in? Seems like a difficult issue to google.

Klyith
Aug 3, 2007

GBS Pledge Week

tuyop posted:

Thanks for pointing that out! I tried just adding "mdns name = server" under [global] and got a systemctl error. Testparm says that it won't work. Is there a specific section this has to go in? Seems like a difficult issue to google.

No, use mdns name = mdns

The options are 'netbios' (use the same name as netbios, default) or 'mdns' (use the same name as dns)

Adbot
ADBOT LOVES YOU

tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe
Oh man, how embarrassing! Thanks, I think that did it

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply