You are not logged in.

#1 2024-04-12 20:15:24

MAYBL8
Member
Registered: 2022-01-14
Posts: 212

[SOLVED] Writing the results of curl command to mirrorlist

I would like the result of the following command to be written to /etc/pacman.d/mirrorlist
I have tried several ways but I either get permission denied or it doesn't write the file

[demo@mail ~]$ curl -s "https://archlinux.org/mirrorlist/?country=US&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 -

Server = https://volico.mm.fcix.net/archlinux/$repo/os/$arch
Server = https://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch
Server = https://mirror.mia11.us.leaseweb.net/archlinux/$repo/os/$arch
Server = https://us.mirrors.cicku.me/archlinux/$repo/os/$arch
Server = https://arlm.tyzoid.com/$repo/os/$arch

Among other ways I have tried this:

[demo@mail ~]$ sudo curl -s "https://archlinux.org/mirrorlist/?country=US&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 >> /etc/pacman.d/mirrorlist

I know this is simple and I should know how to do this but I can't figure it out.  Just need a little help.

This got the file to write but didn't have the above as shown.

demo@mail ~]$ sudo curl -s "https://archlinux.org/mirrorlist/?country=US&protocol=https&use_mirror_status=on" -o /etc/pacman.d/mirrorlist | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 -

Last edited by MAYBL8 (2024-04-14 14:53:02)

Online

#2 2024-04-12 20:56:37

Fixxer
Member
From: Poland
Registered: 2011-08-29
Posts: 217

Re: [SOLVED] Writing the results of curl command to mirrorlist

You can invoke shell with "-c" option to pass command - look at the "man sudo", EXAMPLES section:

To make a usage listing of the directories in the /home partition.  The commands are run in a sub-shell to  allow  the
       ‘cd’ command and file redirection to work.

           $ sudo sh -c "cd /home ; du -s * | sort -rn > USAGE"

Offline

#3 2024-04-12 21:20:21

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,807

Re: [SOLVED] Writing the results of curl command to mirrorlist

Add a final pipe with "sudo tee /etc/pacman.d/mirrorlist" to the end would work as well

Offline

#4 2024-04-13 11:51:50

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,902
Website

Re: [SOLVED] Writing the results of curl command to mirrorlist

Mod note: moving to NC


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2024-04-14 14:52:35

MAYBL8
Member
Registered: 2022-01-14
Posts: 212

Re: [SOLVED] Writing the results of curl command to mirrorlist

Thanks for the help guys.
Sometimes I amaze myself
This worked for me:

sudo sh -c 'curl -s "https://archlinux.org/mirrorlist/?country=US&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 - > /etc/pacman.d/test'

Online

#6 2024-04-14 15:17:30

seth
Member
Registered: 2012-09-03
Posts: 51,739

Re: [SOLVED] Writing the results of curl command to mirrorlist

V1del wrote:

Add a final pipe with "sudo tee /etc/pacman.d/mirrorlist" to the end would work as well

Rule of thumb, the less stuff you have behind sudo, the less harm you're gonna prompt

Offline

Board footer

Powered by FluxBB