Re: Bash / Escaping quotes is driving me crazy . .
by Philip Rhoades
Cameron,
> Date: Tue, 23 Feb 2016 08:39:07 +1100
> From: Cameron Simpson <cs(a)zip.com.au>
> To: phil(a)pricom.com.au, Community support for Fedora users
> <users(a)lists.fedoraproject.org>
> Subject: Re: Bash / Escaping quotes is driving me crazy . .
> Message-ID: <20160222213907.GA79479(a)cskk.homeip.net>
> Content-Type: text/plain; charset=us-ascii; format=flowed
>
> On 21Feb2016 14:18, Philip Rhoades <phil(a)pricom.com.au> wrote:
>>> Date: Sat, 20 Feb 2016 16:40:01 -0800
>>> From: Gordon Messmer <gordon.messmer(a)gmail.com>
> [...]
>>> On 02/20/2016 04:05 PM, Philip Rhoades wrote:
>>>> . . but why is there only a problem with the "flac" OR? - all three
>>>> files have at least one space in the filename:
>>>
>>> Your mistake seems to be believing that the shell can understand the
>>> way
>>> you're nesting quotes. It can't. Each unescaped quote you're using
>>> simply terminates the quoted string that preceded it. So your
>>> example:
>>>
>>> ssh localhost "find
>>> /home/phil/music/ambient/RobertGass+OnWingsOfSong/OmNamahaShivaya
>>> -maxdepth 1 -type f \\( -name "*.mp3" -o -name "*.m4a" -o -name
>>> "*.flac"
>>> \\)"
>
> Because quoting shell commands to dispatch over ssh is tedious, I have
> this
> script:
>
> https://bitbucket.org/cameron_simpson/css/src/tip/bin/sshx
>
> which accepts an unquoted command line and does the work for you, so
> your
> request would be written:
>
> sshx localhost find /your/music/dir -maxdepth 1 -type f \( -name
> \*.mp3 -o -name \*.m4a -o -name \*.flac
>
> i.e. exactly as you would without the leading "ssh localhost" to an
> shell
> prompt.
>
> Please feel free to fetch it (use the "Raw" link at top right) and use
> it. It
> saves a lot of pain.
Excellent! Thanks for that!
> BTW, why "localhost"? Or is this just an example for test, to be used
> on other
> hosts later when working?
Exactly.
>> OK, that all makes sense but there is a further issue - I was trying
>> to keep
>> it simple - this whole line is inside a Ruby "system" command ie:
>>
>> system( "ssh .. " )
>>
>> - so my working version is the same as your first option (without the
>> escaped '*'s) but with an extra '\' at each place. I can't use the
>> second option because I need to use double quotes so that I can use
>> Ruby variables inside the double quotes eg:
>>
>> #{path}
>
> All this means is that you need to take your shell command line, once
> you have
> a working one, and quote it again to express it correctly as a Ruby
> string.
> Bear with me, because I don't yet speak Ruby.
>
> SO first get your shell command line. Make it as simple as feasible. If
> you've
> fetched my "sshx" script, that can be:
>
> sshx localhost find ...
>
> quoted no more than any local "find" command would be. Now express that
> as a
> Ruby string:
>
>
> https://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals#Strings
>
> Since you're using double quotes to allow # interpolation (this is not
> a great
> practive for command lines, to which we'll come later) you probably
> want to
> either run with a command line with no double quotes in it and with all
> the
> backslashes doubled:
>
> shcmd = "sshx localhost find /dir -name \\*.mp3 ..."
>
> If _are_ using a command line with double quotes, they can also be
> escaped, eg:
>
> shcmd = "sshx localhost find /dir -name \"*.mp3\" ..."
>
> I'm imagining that you're expecting to replace "localhost" or the
> directory
> with something like #{remotehost} and #{path} later, thus:
>
> shcmd = "sshx #{remotehost} find #{path} -name \"*.mp3\" ..."
>
> and here we come to the issue of quoting yet again. Supposing your path
> has
> spaces or other shell punctuation in it. You also need to quote it,
> _before_
> using it in your command line string.
>
> I find it useful to have a "shell quote" function in my kit, whatever
> the
> language. You can take any string to be used in the shell undamaged and
> suitable quote it by replacing all single quotes with:
>
> '\''
>
> and enclosing the whole result in a pair of single quotes. You would
> need to do
> this for the variable you want to interpolate:
>
> qpath = shqstr(path)
> qremotehost = shqstr(remotehost)
>
> and then interpolate _those_ values:
>
> shcmd = "sshx #{qremotehost} find #{qpath} -name \"*.mp3\" ..."
>
> and finally running:
>
> system(shcmd)
>
> However, it is better to avoid going through the shell at all if it is
> only an
> intermediary to running a single command (your single "ssh" command).
> Using
> system() with a carefully quoted string has all the same fiddliness as
> passing
> carefully constructed SQL to a database query: any tiny flaw in the
> quoting can
> lead to incorrect behaviour, and if any of the strings come from user
> input,
> that is also an avenue for attack (there are known as injection
> attacks, where
> use input is injected into a command you issue, perverting your
> intent):
>
> http://bobby-tables.com/
>
> The URL above uses SQL because it is an incredibly command misuse, but
> htis
> issue applies equally well to shell commands constructed the way you
> are
> constructing them.
>
> To avoid going though the shell at all you want to invoke your command
> with the
> Subprocess Ruby module:
>
> http://www.rubydoc.info/github/stripe/subprocess/Subprocess
>
> Construct your command as a list of strings:
>
> cmd = ['sshx', remotehost, 'find', path, '-name', '*.mp3', ...]
>
> and invoke Subprocess.popen to collect the resulting output. Notice
> that
> there's no quoting there at all, including of things like *.mp3. This
> is
> because the shell will never see these strings, and therefore you need
> only
> present them directly as valid Ruby strings.
Wow! Thanks for taking the time to answer in such useful detail! I
will have a look at all that - interesting stuff!
And thanks to everyone else who helped as well.
Regards,
Phil.
--
Philip Rhoades
PO Box 896
Cowra NSW 2794
Australia
E-mail: phil(a)pricom.com.au
8 years, 2 months
Re: Bash / Escaping quotes is driving me crazy . .
by Philip Rhoades
Gordon,
> Date: Mon, 22 Feb 2016 08:56:54 -0800
> From: Gordon Messmer <gordon.messmer(a)gmail.com>
> To: users(a)lists.fedoraproject.org
> Subject: Re: Bash / Escaping quotes is driving me crazy . .
> Message-ID: <56CB3DD6.2020909(a)gmail.com>
> Content-Type: text/plain; charset=utf-8; format=flowed
>
> On 02/20/2016 07:18 PM, Philip Rhoades wrote:
>> OK, that all makes sense but there is a further issue - I was trying
>> to keep it simple - this whole line is inside a Ruby "system" command
>> ie:
>> system( "ssh .. " )
>> I can't use the second option because I need to use double quotes so
>> that I can use Ruby variables inside the double quotes eg:
>
> I think you're still missing some fundamental concepts about nesting
> quotes. (I was also mistaken in suggesting that the wildcards needed
> escaping when the internal double-quotes were escaped, though, so...
> We
> all make mistakes.)
>
> In Ruby double-quoted strings, you can get interpolation, and in single
> quoted strings you don't. But if you nest single quotes inside a
> double-quoted strings, Ruby still treats the entire string as double
> quoted. It doesn't change the rules when it finds single quotes inside
> the double-quoted string, because they're merely a part of the
> double-quoted string. So your options are:
>
> system("ssh localhost \"find /home/... -maxdepth 1 -type f \\\\( -name
> \\\"*.mp3\\\" -o -name \\\"*.m4a\\\" -o -name \\\"*.flac\\\" \\\\)\" ")
>
> or:
>
> system("ssh localhost 'find /home/... -maxdepth 1 -type f \\( -name
> \"*.mp3\" -o -name \"*.m4a\" -o -name \"*.flac\" \\)' ")
>
> Using single quotes means significantly less escaping, and you can
> still
> use interpolation in any part of that string, in Ruby.
From another response, what I have actually ended up with is:
system("ssh localhost 'find /home/... -maxdepth 1 -type f \\( -name
\*.mp3 -o -name \*.m4a -o -name \*.flac \\)' ")
Thanks!
Phil.
--
Philip Rhoades
PO Box 896
Cowra NSW 2794
Australia
E-mail: phil(a)pricom.com.au
8 years, 2 months
Re: Bash / Escaping quotes is driving me crazy . .
by Philip Rhoades
People,
> Date: Sat, 20 Feb 2016 18:49:55 -0800
> From: John Wendel <jwendel10(a)comcast.net>
> To: users(a)lists.fedoraproject.org
> Subject: Re: Bash / Escaping quotes is driving me crazy . .
> Message-ID: <56C925D3.5040005(a)comcast.net>
> Content-Type: text/plain; charset=utf-8; format=flowed
>
> On 02/20/2016 04:05 PM, Philip Rhoades wrote:
>> People,
>>
>> This line correctly finds one MP3 but misses two FLACs:
>>
>> ssh localhost "find
>> /home/phil/music/ambient/RobertGass+OnWingsOfSong/OmNamahaShivaya
>> -maxdepth 1 -type f \\( -name "*.mp3" -o -name "*.m4a" -o -name
>> "*.flac" \\)"
>>
>> Adding extra escapes fixes the problem:
>>
>> ssh localhost "find
>> /home/phil/music/ambient/RobertGass+OnWingsOfSong/OmNamahaShivaya
>> -maxdepth 1 -type f \\( -name \"*.mp3\" -o -name \"*.m4a\" -o -name
>> \"*.flac\" \\)"
>>
>> . . but why is there only a problem with the "flac" OR? - all three
>> files have at least one space in the filename:
>>
>> 01_Early Morning.mp3
>> 02 Om.flac
>> 01 Om Namaha Shivaya.flac
>>
>> Thanks,
>>
>> Phil.
>> --
>> Philip Rhoades
>>
>> PO Box 896
>> Cowra NSW 2794
>> Australia
>> E-mail: phil(a)pricom.com.au
>
> I usually resort to running "detox" on the file. Try >man detox.
Thanks for that, detox is nice but if I was going to be thinking about
renaming files in this case I would use my own method eg:
File:
01 Om Namaha Shivaya.flac
detox produces:
01_Om_Namaha_Shivaya.flac
but I would do:
01_OmNamahaShivaya.flac
> Date: Sat, 20 Feb 2016 20:05:19 -0700
> From: jd1008 <jd1008(a)gmail.com>
>
>
> What I do is:
>
> find <some dir> -name \*.mp3 -o -name \*.flac -o -name \*.mp4
>
> and I get ALL the files with those extensions listed.
>
> Notice: No quotes!!!
That is an improvement - thanks!
Phil.
--
Philip Rhoades
PO Box 896
Cowra NSW 2794
Australia
E-mail: phil(a)pricom.com.au
8 years, 2 months
codec missing....
by François Patte
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Bonsoir,
I try to convert a .flac audio file into an mp3 audio file, using the
command:
ffmpeg -i Input.flac -ab 320k -map_metadata 0 -id3v2_version 3 Output.mp
3
This fail with this message:
Encoder (codec none) not found for output stream #0:0
What is missing?
Fedora 21
Thank you
- --
François Patte
UFR de mathématiques et informatique
Laboratoire CNRS MAP5, UMR 8145
Université Paris Descartes
45, rue des Saints Pères
F-75270 Paris Cedex 06
Tél. +33 (0)1 8394 5849
http://www.math-info.univ-paris5.fr/~patte
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iEYEARECAAYFAlbKFLIACgkQdE6C2dhV2JVsMwCgu1QLJOyy5cahzEEkfH3xmvd9
se0AoInqkZKE+4EJrA/kiHMhXT2o7rhu
=xnsV
-----END PGP SIGNATURE-----
8 years, 2 months
Fedora 23 Gnome Online Accounts Issue
by Shawn Iwinski
When trying to add a new Google account to my Fedora 23 Gnome Online
Accounts, I get error "Unacceptable TLS certificate".
Watching "journalctl -f" when trying to add the online account, I see
"org.gnome.ControlCenter.SearchProvider[2580]:
(WebKitWebProcess:5809): GLib-Net-WARNING **: couldn't load TLS file
database: Could not parse PEM certificate: ASN1 parser: Error in DER
parsing."
Googling for a solution has not turned up anything :( Any suggestions?
$ cat /etc/fedora-release
Fedora release 23 (Twenty Three)
$ uname -a
Linux siwinski-fedora-w541 4.3.5-300.fc23.x86_64 #1 SMP Mon Feb 1
03:18:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ rpm -qa | grep -i cert
fedora-cert-0.5.10.5-2.fc23.noarch
ca-certificates-2015.2.6-1.0.fc23.noarch
$ rpm -qa | grep -i gnome-online
gnome-online-accounts-3.18.4-1.fc23.x86_64
gnome-online-miners-3.14.3-3.fc23.x86_64
8 years, 2 months
patch listed as missing
by thibaut noah
Following my kernel compilation issue i used another method to get the
source.
I added :
# custom patch for acs override support
Patch6666: override_for_missing_acs_capabilities.patch
in my kernel.spec
The patch is in rpmbuild/SOURCES but when i run the build it says the file
is missing.
Also to noted i wasn't able to apply the patch following documentation
simply because it seems the patch application changed entirely ?
So either the patch listed is apply automatically with the other in the
code or i need to find the proper place to apply it.
I posted below the command i use to build following by the error message,
second paste is the sources i used.
http://fpaste.org/326707/00190714/
http://ur1.ca/ojtmz
It seems i'm really close to succeeding in the case the patch is workng,
just have to solve this and i should have proper patch kernel
8 years, 2 months
Inconsistencies with tracer
by Patrick O'Callaghan
After updating with dnf I usually run "sudo tracer" to see what needs
to be restarted. I've noticed that the results are often inconsistent,
e.g. after a recent update I get:
You should restart:
* Some applications using:
kdeinit4
* These applications manually:
abrt-applet
chrome
dolphin
evolution
evolution-addressbook-factory
evolution-addressbook-factory-subprocess
evolution-alarm-notify
evolution-calendar-factory
evolution-calendar-factory-subprocess
evolution-source-registry
file.so
firefox
firewall-applet
goa-daemon
goa-identity-service
gvfs-goa-volume-monitor
gvfsd-smb-browse
insync
kaccess
kded5
kdeinit5
kglobalaccel5
kmix
konsole
krunner
kscreen_backend_launcher
ksmserver
kuiserver5
kwalletd5
mission-control-5
plasmashell
polkit-kde-authentication-agent-1
qbittorrent
xembedsniproxy
yakuake
Additionally to those process above, there are:
- 6 processes requiring restart of your session (i.e. Logging out & Logging in again)
Note that last line. I exited the session and immediately logged into a
(non-GUI) console as root, then ran tracer again, getting this:
You should restart:
* Some applications using:
service firewalld restart
service gssproxy restart
service libvirtd restart
service nmbd restart
service smb restart
service sshd restart
service tuned restart
* These applications manually:
cagibid
cupsd
fail2ban-server
rsyslogd
Additionally to those process above, there are:
- 1 processes requiring reboot
Again. note the last line. So there are two issues here:
1) The first run of tracer didn't spot a bunch of services and other
demons that needed to be restarted.
2) It also didn't spot that I needed to reboot, meaning that just
logging out and in again would not have left me with a consistent
system.
Not sure if this can be classed as a bug or a feature.
poc
8 years, 2 months
Helping improve support for Thinkpad P70
by Digimer
Hi all,
After much struggling with Fedora 23 and CentOS 7 on a new Thinkpad
P70, I failed to get things working well. With all stock
install/updates, using "hybrid" graphics (intel + nvidia m600m), I would
get a black bar along the bottom of the screen that wouldn't display,
but was there (I could type, but not see what I typed, in full screen
terminals for example).
If I switched to pure nvidia (discrete mode), I would get 1024x768 on
the nouveau drivers. I tried the RPMfusion nvidia drivers and it would
work for a short time only. First time that I suspended the laptop, I'd
lose the screen for good, even after a power cycle (text mode during
boot would show, but nothing when gnome started), but I could SSH into
it so the system was OK. So on and so forth with Fedora, CentOS, EPEL
kernel-ml, etc.
I decided to try ubuntu, just to see if it was linux itself, but it
appears to work out of the box. So I am pretty sure that Linux in
general is OK (at least workable). It's a 4k screen on the laptop, for
what it matters.
My question then is this;
How/what can I do, as a user, to help improve support for this machine
under Fedora (and RHEL/CentOS)? I'm a sysadmin who works with EL, so I'd
really like to make this machine work in fedora where I am most
comfortable. :)
Thanks!
--
Digimer
Papers and Projects: https://alteeve.ca/w/
What if the cure for cancer is trapped in the mind of a person without
access to education?
8 years, 2 months
Re: Desktop Does Not Start Up
by Richard Ibbotson
Hi
I thought I should reply to this one due to the fact that I think that
no one else is going to work it out... Would be useful to leave this
in the Fedora Users archive....
> I did a dnf update on my F23 workstation. After rebooting to make
> sure that the updates were working properly I find that I can't get
> to the login screen. I see the blue Fedora logo for a split second.
> Then the command line appears with a message to do Ctrl-D or login
as
> root. Nouveau drivers for the graphics card. I can login as root
and
> use a text editor. After the failed X startup I can see the
> following error message on the screen
>
> Error getting authority: Error initialization authority: Could not
> connect: No such file or directory (g-io-error-quark, 1)
>
> If I have a look at the log in /home/user/.local/share/xorg it
says...
>
> Fatal server error: xf86OpenConsole: Cannot open virtual console 1
> (Permission
> denied.
> If I try startx as as a user or as root I can see.. for example...
in
> /var/log/Xorg.0.log...
>
> dbus core: error connecting to system bus:
> org.freedesktop.Dbus.Error.FileNotFound (Failed to connect to socket
> /run/dbus/system_bus_socket: No such file or directory)
>
> Can anyone suggest how to fix this ? I can't send in lengthy logs due
> to the fact that I can't ssh into the machine or run a second or
> third console. Access to one console only.
The answer this one is....
https://askubuntu.com/questions/631362/error-getting-authority-error-init...
“ Add the option nofail to the failing mount point or all the mount
points that are not required at boot time. “ That fixed it. Working fine
now :)
Thank you.
--
Richard
Sheffield UK
8 years, 2 months