You are not logged in.
Eschwartz, I'd ask similar questions about netctl in general over wpa_supplicant and wpa_passprhase.
The reason would be menu-driven configuration over editing wpa_supplicant.conf -- regarding which, I don't actually know of a way to completely automate reconnecting to an SSID, but then again I've never actually tried to find out.
...Oh, I wasn't even aware that wpa_passphrase existed to generate wpa_supplicant.conf entries. Interesting. TIL.
So I guess you could write your own script(s) to use that for network management purposes, but eventually you end up reimplementing netctl anyway.
...
Anyway, the main point here is that if you are going to use netctl *anyway*, you might as well use it instead of calling it via a script that reimplements what netctl (the thing you elected to use) already does.
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
So I guess you could write your own script(s) to use that for network management purposes, but eventually you end up reimplementing netctl anyway.
Or just use dhcpcd.service with the wpa_supplicant hook and all of the above is included. Or just wpa_supplicant.service if you don't use dhcpcd.
If you need menu driven, wpa_cli (included with wpa_supplicant) is pretty close.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Trilby wrote:Eschwartz, I'd ask similar questions about netctl in general over wpa_supplicant and wpa_passprhase.
The reason would be menu-driven configuration over editing wpa_supplicant.conf -- regarding which, I don't actually know of a way to completely automate reconnecting to an SSID, but then again I've never actually tried to find out.
I use systemd-networkd with wpa_supplicant, and it does automatically reconnect to an SSID in case the connection drops. I don't know whether it supports profiles like netctl though.
Desktop screenshots :: Origami :: github
Offline
"Profiles" are just a really complicated and indirect way of managing a wpa_supplicant.conf. They are almost verbatim wpa_supplicant.conf excerpts just with very odd quoting rules that make them error prone.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
What is the advantage of this over netctl's wifi-menu for interactively selecting the ESSID to connect to, and saving netctl profiles for use with the netctl-auto service?
Or the NetworkManager daemon with either nmtui (console) or network-manager-applet (gui) as a frontend?
None at all.
Except that I didn't realize wifi-menu came with netctl! :-)
Oh, well. It was fun writing the script anyway.
Offline
This reminds me of my pressing need for a multiple-backend networking indicator. Really need to get working on that.
makepkg-optimize · indicator-powersave · pantheon-{3d,lite} · {pantheon,higan}-qq
Offline
I wrote a tool to let me rename files per regex without having to be annoyed over the sed syntax.
https://bitbucket.org/tux_/remv
Offline
Why, oh why, did you ever think that piping `ls|sed|sh` was a good idea?
Moreover, when the standard bulk file renaming utility is https://www.archlinux.org/packages/comm … rl-rename/
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Not everyone knows all the options.
Oops! Thanks...
Offline
Well, maybe not everyone knows all the options. But I'm more concerned at your initial fallback on https://mywiki.wooledge.org/ParsingLs, and as for piping to sh, that seems to be an innovative variety of the well-known disaster called "using eval" (eval has a small number of uses, and a vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, vast, number of horrible and ill-advised uses. No, that over-repetition of "vast" is neither a mistake nor an overexaggeration.)
None of this should have ever been your first fallback. Good bash programmers will try basically anything up to and including renaming everything by hand, out of fear of what this could accidentally do.
If you really wanted to use sed for this, you can. Just, please use find -print0 with sed's -z option, and pipe it to xargs! find is filename-safe for scripts, as it explicitly processes filenames as opposed to a formatted table that merely includes filenames, and using null-delimited input/output with both is something that should always be the first thing you try to convince your tools to use.
Last edited by eschwartz (2018-01-14 21:29:25)
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
The disadvantage of the sed approach is that it's not really portable, not even in the Unix/Linux world (GNU sed vs. BSD sed - modify the options and you're doomed). This was my main motivation to write my own answer to this problem: No Windows support here. - That Perl thing would probably work though. Goodbye, motivation!
Offline
I'm impressed you did all that in C++!
Goodbye, motivation!
That's why I always choose video games as my programming projects. There's always new ideas, and Linux doesn't have nearly enough of them.
Offline
C or Lisp (which I considered first) would probably have made my tool more nerdish, but C++ has everything I need in its standard library now, so it was a logical choice to me.
Last edited by YesItsMe (2018-01-15 02:33:33)
Offline
C or Lisp (which I considered first) would probably have made my tool more nerdish, but C++ has everything I need in its standard library now, so it was a logical choice to me.
If you want everything in the standard library, the logical choice is python, especially when dealing with strings
As an aside, Thunar has a sweet GUI for bulk renaming. The option to preview changes is quite handy when using regex
Desktop screenshots :: Origami :: github
Offline
The disadvantages of Python (to me) are the lack of brackets and the awful performance. I prefer not to deal with it.
Thunar would again not be quite as portable as I intended it to.
Offline
Here are two tiny scripts that I made to be called as keyboard shortcuts (from xfce4):
1. Multi-timezone clock. I didn't want to dive into the endless pool of desktop widgets and panel plugins (I have only workspace switcher on my panel), so here is clockterm.sh
#!/bin/bash
TPUT=/usr/bin/tput
DATE=/usr/bin/date
TZp=/usr/share/zoneinfo
red=$($TPUT setaf 1)
green=$($TPUT setaf 2)
blue=$($TPUT setaf 4)
rst=$($TPUT sgr0)
f='+%l:%M%P %Z'
/usr/bin/xterm -geometry 13x4-0+0 -T "$($DATE '+%a %m/%d')" \
-fa "DejaVu Sans Mono:size=20:antialias=true" -e /usr/bin/bash -c "\
echo -E \" $(TZ= $DATE "$f")\"
echo -E \" ${blue}$(TZ=${TZp}/Europe/London $DATE "$f")${rst}\"
echo -E \" ${green}$(TZ=${TZp}/America/New_York $DATE "$f")${rst}\"
echo -nE \" ${red}$(TZ=${TZp}/America/Denver $DATE "$f")${rst}\"
sleep 10"
2. The 2nd utility has to do with locking the screen. I usually have multiple Xephyr windows that host forwarded X11 connections from remote machines. They have a nasty habit of grabbing my keyboard, so when I press CTRL-ALT-L to call xscreensaver, nothing happens. Pressing this key combo became so much of a reflex that I often press it while standing up and walk away immediately leaving my screen unlocked. Therefore, I need some visual indication that the screensaver is about to be activated. Also, I often log in to tty as well as X. Obviously, locking the X session leaves tty's unprotected, so I figured it would be useful to see what's running on those consoles when triggering the screensaver.
#!/bin/bash
/usr/bin/xterm -geometry 50x57-0+0 -bg blue -fg darkgrey \
-fa "DejaVu Sans Mono:size=10:antialias=true" \
-T "$(/usr/bin/date '+%l:%M%P %Z')" -e /usr/bin/bash -c "\
/usr/bin/tput bold
for n in {1..12}; do
p=\"\$(/usr/bin/ps --no-headers -t tty\$n)\"
if [[ -n \"\$p\" ]]; then
echo -E \"--- TTY_\$n ---\"
echo -E \"\$p\"
echo -E \"\"
fi
done
sleep 10"
/usr/bin/xscreensaver-command -lock && /usr/bin/logger "Locking screen"
Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd
Offline
The disadvantages of Python (to me) are the lack of brackets and the awful performance.
I used to think this too, but modern python has completely changed my mind (about the performance point).
There is a lot of bad python code out there that does indeed perform horribly. Bad algorithms will always perform badly. But much of python is, or can be, fully compiled. Anything in the performance critical bits of any script should be using the compiled and highly optimized library routines (e.g. numpy/scipy for numeric or scientific computation).
C is my primary language. But for many purposes, writing something in python will yeild a result just as fast as the C version.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Here's 1 of dozens of scripts I've been studying that started as a test from the book Learn Ruby The Hard Way. This is that
completed and added to, hopefully mastered minus a single lingering mystery.
I found it extrememly helpful for memorizing syntax and a number of other basic and important fundamentals. Amazing amount of
variety for it's length. I've been rewriting it for weeks and have moved on to improvements to it. Quite happy about it.
Can move onto the next focus.
I leave this here for those looking for a good Ruby script study and that is really all it is good for. Was useful for me.
The links are my complete version, it's output and a raw script to rebuild as an improved "test" for anyone curious to try it.
Oh! And I shouuld mention I am dangerously unPC and those easily offended should absolutely skip everything I ever write... ever.
That said. Hope it helps somebody.
My output is here:
https://paste.pound-python.org/show/Prp … sacEgSmTv/
A cat of the improved script (30% more free!) here:
https://paste.pound-python.org/show/WfU … Mx3XELdUv/
And heres the test. Covers a whole lot:
https://paste.pound-python.org/show/16N … L72tEeg1j/
The mystery? I used implied returns throughout the script yet only in one small stand-alone scriptette does it demand a proper typed
return. Funny. I'll figure it out. Picky little bugger. Don't look to be much Ruby here anyway.
Hoping to have things useful for other than study soon. Best 'o luck.
Offline
Little script for getting lengths of video segments. Such as when editing your favorite tv show that you captured.
#! /usr/bin/env bash
clear
echo -e "Video segment calculator. Enter time with format 01:23:34\n"
while :; do
read -p "Enter Start time: " start_time
read -p "Enter Stop time: " stop_time
StartDate=$(date -d "$start_time" +"%s")
EndDate=$(date -d "$stop_time" +"%s")
Diff=$(date -d "0 $EndDate sec - $StartDate sec" +"%H:%M:%S")
echo " ----------"
echo "Difference is: "$Diff""
echo "---------------------------"
echo "ffmpeg -ss "$start_time" -t "$Diff""
echo "================================="
done
Offline
Little script to check for file/url existence and file size.
#! /usr/bin/env bash
#Check if remote file/url exists - file size
#List of User agents for requests
#Win 8 Firefox
a="Mozilla/5.0 (Windows NT 6.2; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0"
#iPhone 6
b="Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_4 like Mac OS X) AppleWebKit/536.26 \
(KHTML, like Gecko) Version/6.0 Mobile/10B350 Safari/8536.25"
#Linux Chrome
c="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) \
Chrome/61.0.2785.89 Safari/537.36"
#Googlebot
d="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
#Generic
e="Mozilla/5.0"
#Set user agent here
agent="$a"
read -p "Enter url to check: " url
#Use one
wget -U "$agent" --spider "$url"
#curl -LA "$agent" -I "$url"
#lynx -useragent="$agent" -head -dump "$url"
#HEAD -H "User-Agent: $agent" "$url"
#echo "user_agent "$agent"" > ~/.w3m/config
#w3m -dump_head "$url"
Offline
Make lynx a little easier to use.
#! /usr/bin/env bash
#lnx.sh
#For larger version example:
#xterm -fa 'Monospace' -fs 18 -g 90x34 -e ./lnx.sh
#Add/Subtract Bookmarks here.
Bookmarks=$(echo '
<!DOCTYPE HTML>
<html lang = "en">
<head>
<title>Bookmarks</title>
<meta charset = "UTF-8" />
<style type = "text/css">
table , td, th { vertical-align: top;
order: 0px solid black;}
</style>
</head>
<body>
<h1>Bookmarks</h1>
<h3>Search</h3>
<dt><a href="http://www.google.com/" >Google</a>
<dt><a href="http://www.bing.com/" >Bing</a>
<dt><a href="https://duckduckgo.com/lite/" >DuckDuckGo</a>
<dt><a href="http://en.wikipedia.org/wiki/Special" >Wikipedia</a>
<dt><a href"https://www.youtube.com/" >YouTube</a>
<h3>Linux</h3>
<dt><a href="http://www.linuxquestions.org/questions" >LinuxQuestions</a>
<dt><a href="http://www.archlinux.org/" >Arch Linux</a>
<dt><a href="https://aur.archlinux.org/" >Arch AUR</a>
<dt><a href="https://wiki.archlinux.org/index.php/Arch_Linux_Archive" >Arch Archive</a>
<dt><a href="https://bbs.archlinux.org/help.php" >Arcs BBS help</a>
<h3>News</h3>
<dt><a href="http://m.dw.de/english/" >DW</a>
<dt><a href="http://www.spiegel.de/international/" >Spiegel</a>
<dt><a href="http://www.news.com.au/" >News Au</a>
<dt><a href="http://www.dutchnews.nl/" >Dutch News</a>
<dt><a href="http://elpais.com/elpais/inenglish.html" >El Pais</a>
<h3>Other</h3>
<dt><a href="http://lynx.invisible-island.net/lynx_help/keystrokes/keystroke_help.html" >Lynx keys</a>
<dt><a href="http://www.whattimeisit.com/" >Corect time</a>
<dt><a href="https://mail.google.com/mail/" >Gmail</a>
<dt><a href="http://www.pbs.org/video/" >PBS Vids</a>
<dt><a href="http://www.whitepages.com/" >White pages</a>
</body>
</html>
')
#User agent to report
agent="Mozilla/5.0"
#Main loop
while :; do
clear
#Get user input
read -p $'Press Enter for Bookmarks or Enter/Paste url \n: ' url
#If none then open bookmarks
if [ -z "$url" ]; then
echo "${Bookmarks[@]}" |
lynx -image_links -accept_all_cookies -useragent="$agent" --stdin
#Or open the url
else
lynx -image_links -accept_all_cookies -useragent="$agent" "$url"
fi
done
Offline
teckk,
I wonder, is it legal to have Googlebot as a user agent? What if someone has blocked crawling his site by search engines in robots.txt and after that sees Googlebot reading his pages?
bing different
Offline
What if someone has blocked crawling his site by search engines in robots.txt and after that sees Googlebot reading his pages?
The robots.txt file is only a suggestion of what a site would like to allow access to, there is nothing at all to say it has to be legally adhered to.
Offline
nbd wrote:What if someone has blocked crawling his site by search engines in robots.txt and after that sees Googlebot reading his pages?
The robots.txt file is only a suggestion of what a site would like to allow access to, there is nothing at all to say it has to be legally adhered to.
I meant something different. If someone blocked his site and sees Googlebot in his logs, he can start to complain to Google, which states that it abides to robots.txt.
bing different
Offline
The page you linked to clearly links to this...
Verifying Googlebot
If they complain to Google then they're doing it wrong.
Offline