Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Life would be so much easier if we could just look at the source code. -- Dave Olson


aus+uk / uk.comp.os.linux / Re: Lost in space(s)

SubjectAuthor
* Lost in space(s)Jim Lesurf
+* Re: Lost in space(s)Theo
|`* Re: Lost in space(s)Jim Lesurf
| +- Re: Lost in space(s)Theo
| `- Re: Lost in space(s)Richard Kettlewell
`* Re: Lost in space(s)Folderol
 +* Re: Lost in space(s)Aragorn
 |`- Re: Lost in space(s)Aragorn
 `- Re: Lost in space(s)Folderol

1
Lost in space(s)

<59eeaca9fenoise@audiomisc.co.uk>

  copy mid

https://www.novabbs.com/aus+uk/article-flat.php?id=708&group=uk.comp.os.linux#708

  copy link   Newsgroups: uk.comp.os.linux
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!nntp.orpheusnet.co.uk!news.orpheusnet.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 26 May 2022 09:23:56 -0500
From: noi...@audiomisc.co.uk (Jim Lesurf)
Subject: Lost in space(s)
Newsgroups: uk.comp.os.linux
Date: Thu, 26 May 2022 15:23:44 +0100
Message-ID: <59eeaca9fenoise@audiomisc.co.uk>
User-Agent: Pluto/3.18 (RISC OS/5.29) NewsHound/1.43-32pre3
Organization: None
Cache-Post-Path: slave.orpheusnet.co.uk!unknown@82.152.193.78
X-Cache: nntpcache 3.0.2 (see http://www.nntpcache.com/)
Lines: 65
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-HZZisxMuBRMR8Vfy1U920ppk0zTrXq2c/gyY8MfVsNeeyMz/NJSO4pJIvZ1Od9kegpDMxXQRhV12lzQ!XONX/GJNx0bNB1pF51TfzAwLLtV8ZcaeJIQWNjRM+aNbwaTDmH+qlluDwufKRAegPCXx7NSJXIg=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 3779
 by: Jim Lesurf - Thu, 26 May 2022 14:23 UTC

I tend to run ROX-Filer on my Linux machines and then write simple ROX
'apps' as a way to carry out various simple routine file-processing tasks.
Overall this works fine for me, but in some cases I hit a snag that I don't
know how to deal with. The cause is common, so maybe someone here can
point out how I can deal with it...

For those who don't use it: A Rox 'app' essentially is a directory that
contains some specific items the filer uses to tell it is an app, not a
plain directory. The entry point is an executable file with the name
"AppRun". The contents are read and executed. Typically I use this to
contain something like

#! /bin/sh

exec xterm -fn 10x20 -sb -rightbar -sl 200 -hold -e `dirname $0`/RunImage
"$@"

(exec command all on one line)

This then calls the main code in the file 'RunImage' in the app and runs it
in a terminal. The main code I generate from a 'C' program as most of my
programming is in 'C'.

As you'd expect it executes the RunImage and sends it the context info via
the "$@" for the program to get via its 'environment' 'arguments' input. In
particular, if I drag-and-drop a file icon onto the app's directory icon
ROX runs the app and gives it the full pathname of the file via the above.
So the program can find it as an input argument. Thus knows what file I
want it to deal with.

The snag is when I want to process a file provided by someone else *which
contains space characters (or some other 'control' characters)*.

e.g. the input file may have a leafname "fred the frog.mkv" rather than
"fred_the_frog.mkv".

The spaces cause only the initial "fred" to be sent as the input file name.
So the RunImage doesn't get the full *actual* name. (the args count remains
'2'.)

This is presumably because I shouldn't be using "$@" but some other spec
that gets the file name sent as a one complete string including the spaces.
But my noddy knowledge of bash, etc, means I dunno how to fix this. So can
someone explain, please how to get such names sent as a fill file name
series of characters. Not split up and lost.

Personally I regard spaces in file names as a PITA, so never use them
myself. But others do and I then have to 'edit' the names at present to
avoid the above problem.

BTW if you want to see examples of the ROX apps you can find some here
http://www.audiomisc.co.uk/software/index.html
mixed in with RISC OS equivalents. Apologies as the programs aren't pretty,
I'm not a real programmer, but they get the job done in general.

Ta,

Jim

--
Please use the address on the audiomisc page if you wish to email me.
Electronics https://www.st-andrews.ac.uk/~www_pa/Scots_Guide/intro/electron.htm
biog http://jcgl.orpheusweb.co.uk/history/ups_and_downs.html
Audio Misc http://www.audiomisc.co.uk/index.html

Re: Lost in space(s)

<T-B*rkdPy@news.chiark.greenend.org.uk>

  copy mid

https://www.novabbs.com/aus+uk/article-flat.php?id=709&group=uk.comp.os.linux#709

  copy link   Newsgroups: uk.comp.os.linux
Path: i2pn2.org!i2pn.org!aioe.org!nntp.terraraq.uk!nntp-feed.chiark.greenend.org.uk!ewrotcd!.POSTED!not-for-mail
From: theom+n...@chiark.greenend.org.uk (Theo)
Newsgroups: uk.comp.os.linux
Subject: Re: Lost in space(s)
Date: 27 May 2022 13:55:33 +0100 (BST)
Organization: University of Cambridge, England
Lines: 58
Message-ID: <T-B*rkdPy@news.chiark.greenend.org.uk>
References: <59eeaca9fenoise@audiomisc.co.uk>
NNTP-Posting-Host: chiark.greenend.org.uk
X-Trace: chiark.greenend.org.uk 1653656135 5009 212.13.197.229 (27 May 2022 12:55:35 GMT)
X-Complaints-To: abuse@chiark.greenend.org.uk
NNTP-Posting-Date: Fri, 27 May 2022 12:55:35 +0000 (UTC)
User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (Linux/3.16.0-11-amd64 (x86_64))
Originator: theom@chiark.greenend.org.uk ([212.13.197.229])
 by: Theo - Fri, 27 May 2022 12:55 UTC

Jim Lesurf <noise@audiomisc.co.uk> wrote:
> #! /bin/sh
>
> exec xterm -fn 10x20 -sb -rightbar -sl 200 -hold -e `dirname $0`/RunImage
> "$@"
>
> (exec command all on one line)
>
> This then calls the main code in the file 'RunImage' in the app and runs it
> in a terminal. The main code I generate from a 'C' program as most of my
> programming is in 'C'.
>
> As you'd expect it executes the RunImage and sends it the context info via
> the "$@" for the program to get via its 'environment' 'arguments' input. In
> particular, if I drag-and-drop a file icon onto the app's directory icon
> ROX runs the app and gives it the full pathname of the file via the above.
> So the program can find it as an input argument. Thus knows what file I
> want it to deal with.

Sigh, shell and whitespace is always a mess. However:
https://yakking.branchable.com/posts/whitespace-safety/

$ cat printargs.c
#include <stdio.h>
int main(int argc, char *argv[])
{ int i=0;
while (argc) {
printf("%s\n", argv[i]);
i++;
argc--;
}
}

$ gcc -o printargs printargs.c

$ ./printargs "hello world" something else
../printargs
hello world
something
else
$ bash
$ set -- "hello world" something else
$ ./printargs "$@"
../printargs
hello world
something
else
$ exec ./printargs "$@"
../printargs
hello world
something
else

So "$@" should do the right thing, and I'm puzzled why it doesn't. Perhaps
xterm or your RunImage isn't handling args in the right way?

Theo

Re: Lost in space(s)

<59ef2fe763noise@audiomisc.co.uk>

  copy mid

https://www.novabbs.com/aus+uk/article-flat.php?id=710&group=uk.comp.os.linux#710

  copy link   Newsgroups: uk.comp.os.linux
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!nntp.orpheusnet.co.uk!news.orpheusnet.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 27 May 2022 09:19:32 -0500
From: noi...@audiomisc.co.uk (Jim Lesurf)
Subject: Re: Lost in space(s)
Newsgroups: uk.comp.os.linux
Date: Fri, 27 May 2022 15:17:13 +0100
Message-ID: <59ef2fe763noise@audiomisc.co.uk>
References: <59eeaca9fenoise@audiomisc.co.uk> <T-B*rkdPy@news.chiark.greenend.org.uk>
User-Agent: Pluto/3.18 (RISC OS/5.29) NewsHound/1.43-32pre3
Organization: None
Cache-Post-Path: slave.orpheusnet.co.uk!unknown@82.152.193.78
X-Cache: nntpcache 3.0.2 (see http://www.nntpcache.com/)
Lines: 41
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-lKyAmuCYY9Zg7SP+xnsjv7C4K4AIC2BL7xg5BYdsqlqI+WyqQrhQveAna0XU2Lj4+N9xZfRQIFo9zc2!N81XrpYD2ST5rqEyvykGUXQZ3/9+oBULJYTnaRjVShyZUZaECjXEIooCFyEXM05qbBKmTvJzwIw=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 2910
 by: Jim Lesurf - Fri, 27 May 2022 14:17 UTC

In article <T-B*rkdPy@news.chiark.greenend.org.uk>, Theo
<theom+news@chiark.greenend.org.uk> wrote:

> So "$@" should do the right thing, and I'm puzzled why it doesn't.

<AOL> Me too! :-//

> Perhaps xterm or your RunImage isn't handling args in the right way?

Quite possibly. I'm a lousy programmer. However when I tried and got my
current program to print out the arg count 'seen' by the executable
'RunImage' I'd generated from 'C' using gcc it always gives the arguments
count as '2'. Which I assume implies that the launching code ending with
"$@" is only sending until the first space in the filename it got.

Maybe this is a bug (aka 'feature') in ROX-Filer? And when *it* sends the
file name to AppRun (the code that starts the xterm, etc) *it* fails to
read everything after the first space in the name of the file dropped on
the ROX-app icon. :-/ If so, real PITA!

If curious, there are examples of what I've already written here
http://www.audiomisc.co.uk/software/index.html
including the sources.

The only dodge I've thought of thus far is to put 'spaced-out' files into a
specific input directory. Then a click on the ROX app icon can make it cat
the directory content list of file names into a text file to get the
name(s) with spaces - and then use that list to change the names. (i.e.
force the C to read each line until it hits an EOF or return.That should
sidestep the problem. But it shouldn't really be happening at all. I've
assumed this is for the usual reason - I'm a crap programmer. But maybe
it's something else this time.

Jim

--
Please use the address on the audiomisc page if you wish to email me.
Electronics https://www.st-andrews.ac.uk/~www_pa/Scots_Guide/intro/electron.htm
biog http://jcgl.orpheusweb.co.uk/history/ups_and_downs.html
Audio Misc http://www.audiomisc.co.uk/index.html

Re: Lost in space(s)

<U-B*RTdPy@news.chiark.greenend.org.uk>

  copy mid

https://www.novabbs.com/aus+uk/article-flat.php?id=711&group=uk.comp.os.linux#711

  copy link   Newsgroups: uk.comp.os.linux
Path: i2pn2.org!i2pn.org!paganini.bofh.team!newsfeed.xs3.de!callisto.xs3.de!nntp-feed.chiark.greenend.org.uk!ewrotcd!.POSTED!not-for-mail
From: theom+n...@chiark.greenend.org.uk (Theo)
Newsgroups: uk.comp.os.linux
Subject: Re: Lost in space(s)
Date: 27 May 2022 16:26:38 +0100 (BST)
Organization: University of Cambridge, England
Lines: 23
Message-ID: <U-B*RTdPy@news.chiark.greenend.org.uk>
References: <59eeaca9fenoise@audiomisc.co.uk> <T-B*rkdPy@news.chiark.greenend.org.uk> <59ef2fe763noise@audiomisc.co.uk>
NNTP-Posting-Host: chiark.greenend.org.uk
X-Trace: chiark.greenend.org.uk 1653665200 20084 212.13.197.229 (27 May 2022 15:26:40 GMT)
X-Complaints-To: abuse@chiark.greenend.org.uk
NNTP-Posting-Date: Fri, 27 May 2022 15:26:40 +0000 (UTC)
User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (Linux/3.16.0-11-amd64 (x86_64))
Originator: theom@chiark.greenend.org.uk ([212.13.197.229])
 by: Theo - Fri, 27 May 2022 15:26 UTC

Jim Lesurf <noise@audiomisc.co.uk> wrote:
> Quite possibly. I'm a lousy programmer. However when I tried and got my
> current program to print out the arg count 'seen' by the executable
> 'RunImage' I'd generated from 'C' using gcc it always gives the arguments
> count as '2'. Which I assume implies that the launching code ending with
> "$@" is only sending until the first space in the filename it got.
>
> Maybe this is a bug (aka 'feature') in ROX-Filer? And when *it* sends the
> file name to AppRun (the code that starts the xterm, etc) *it* fails to
> read everything after the first space in the name of the file dropped on
> the ROX-app icon. :-/ If so, real PITA!

I think you might have to do some digging. My 'printargs' example does the
right thing, so maybe you could try running that under ROX (piping stdout to
a file if needs be to capture the output) and see if it works. And then try
running your app with "$@" after doing a 'set --' to force the args. Also
try running printargs in xterm. Could be xterm, could be ROX, could be
something else - more needed investigation to get to the bottom of it.

Note that argc includes the program name, so running the binary with no args
would give argc=1.

Theo

Re: Lost in space(s)

<87zgj3ug1o.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://www.novabbs.com/aus+uk/article-flat.php?id=712&group=uk.comp.os.linux#712

  copy link   Newsgroups: uk.comp.os.linux
Path: i2pn2.org!i2pn.org!news.nntp4.net!nntp.terraraq.uk!.POSTED.nntp.terraraq.uk!not-for-mail
From: inva...@invalid.invalid (Richard Kettlewell)
Newsgroups: uk.comp.os.linux
Subject: Re: Lost in space(s)
Date: Fri, 27 May 2022 16:54:43 +0100
Organization: terraraq NNTP server
Message-ID: <87zgj3ug1o.fsf@LkoBDZeT.terraraq.uk>
References: <59eeaca9fenoise@audiomisc.co.uk>
<T-B*rkdPy@news.chiark.greenend.org.uk>
<59ef2fe763noise@audiomisc.co.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: mantic.terraraq.uk; posting-host="nntp.terraraq.uk:2a00:1098:0:86:1000:3f:0:2";
logging-data="386"; mail-complaints-to="usenet@mantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:BuOIH2w1li5eHApjyUMW/L/rpUw=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Fri, 27 May 2022 15:54 UTC

Jim Lesurf <noise@audiomisc.co.uk> writes:
> Theo> <theom+news@chiark.greenend.org.uk> wrote:
>> So "$@" should do the right thing, and I'm puzzled why it doesn't.
>
> <AOL> Me too! :-//
>
>> Perhaps xterm or your RunImage isn't handling args in the right way?
>
> Quite possibly. I'm a lousy programmer. However when I tried and got my
> current program to print out the arg count 'seen' by the executable
> 'RunImage' I'd generated from 'C' using gcc it always gives the arguments
> count as '2'. Which I assume implies that the launching code ending with
> "$@" is only sending until the first space in the filename it got.

My first step would be to use strace to find out where things go
wrong. Specifically find the PID of rox-filer, then run:

strace -o trace -e trace=execve -p PID

The ‘trace’ file should end up with the commands actually executed and
their arguments. It should be enough to figure out which component has
gone wrong.

Your script looked OK and the _current_ rox-filer source looks OK, but I
don’t know what version you’re running.

> Maybe this is a bug (aka 'feature') in ROX-Filer? And when *it* sends the
> file name to AppRun (the code that starts the xterm, etc) *it* fails to
> read everything after the first space in the name of the file dropped on
> the ROX-app icon. :-/ If so, real PITA!

If, hypothetically, it just concatenated the AppRun path and the
filename and passed the result to the shell then you’d get the behavior
you see, since the shell would see each part of the filename as a
separate argument.

--
https://www.greenend.org.uk/rjk/

Re: Lost in space(s)

<20220723144902.2d890bc7@devuan>

  copy mid

https://www.novabbs.com/aus+uk/article-flat.php?id=713&group=uk.comp.os.linux#713

  copy link   Newsgroups: uk.comp.os.linux
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: gene...@musically.me.uk (Folderol)
Newsgroups: uk.comp.os.linux
Subject: Re: Lost in space(s)
Date: Sat, 23 Jul 2022 14:49:02 +0100
Organization: A noiseless patient Spider
Lines: 71
Message-ID: <20220723144902.2d890bc7@devuan>
References: <59eeaca9fenoise@audiomisc.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="9326d5f1cc124a98612a6e7cbf6ccf24";
logging-data="4109386"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18j5IlZCN/zWkFtaCIGU56MZ5I0r6NPW7M="
Cancel-Lock: sha1:bJ6Qatr6GnmOL+hTltSFBynrUlc=
X-Newsreader: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu)
 by: Folderol - Sat, 23 Jul 2022 13:49 UTC

On Thu, 26 May 2022 15:23:44 +0100
Jim Lesurf <noise@audiomisc.co.uk> wrote:

>I tend to run ROX-Filer on my Linux machines and then write simple ROX
>'apps' as a way to carry out various simple routine file-processing tasks.
>Overall this works fine for me, but in some cases I hit a snag that I don't
>know how to deal with. The cause is common, so maybe someone here can
>point out how I can deal with it...
>
>For those who don't use it: A Rox 'app' essentially is a directory that
>contains some specific items the filer uses to tell it is an app, not a
>plain directory. The entry point is an executable file with the name
>"AppRun". The contents are read and executed. Typically I use this to
>contain something like
>
>#! /bin/sh
>
>exec xterm -fn 10x20 -sb -rightbar -sl 200 -hold -e `dirname $0`/RunImage
>"$@"
>
>(exec command all on one line)
>
>This then calls the main code in the file 'RunImage' in the app and runs it
>in a terminal. The main code I generate from a 'C' program as most of my
>programming is in 'C'.
>
>As you'd expect it executes the RunImage and sends it the context info via
>the "$@" for the program to get via its 'environment' 'arguments' input. In
>particular, if I drag-and-drop a file icon onto the app's directory icon
>ROX runs the app and gives it the full pathname of the file via the above.
>So the program can find it as an input argument. Thus knows what file I
>want it to deal with.
>
>The snag is when I want to process a file provided by someone else *which
>contains space characters (or some other 'control' characters)*.
>
>e.g. the input file may have a leafname "fred the frog.mkv" rather than
>"fred_the_frog.mkv".
>
>The spaces cause only the initial "fred" to be sent as the input file name.
>So the RunImage doesn't get the full *actual* name. (the args count remains
>'2'.)
>
>This is presumably because I shouldn't be using "$@" but some other spec
>that gets the file name sent as a one complete string including the spaces.
>But my noddy knowledge of bash, etc, means I dunno how to fix this. So can
>someone explain, please how to get such names sent as a fill file name
>series of characters. Not split up and lost.
>
>Personally I regard spaces in file names as a PITA, so never use them
>myself. But others do and I then have to 'edit' the names at present to
>avoid the above problem.
>
>BTW if you want to see examples of the ROX apps you can find some here
>http://www.audiomisc.co.uk/software/index.html
>mixed in with RISC OS equivalents. Apologies as the programs aren't pretty,
>I'm not a real programmer, but they get the job done in general.
>
>Ta,
>
>Jim
>

Bit late, but is this what you are looking for?

for f in *\ *; do mv "$f" "${f// /_}"; done

--
Basic

Re: Lost in space(s)

<20220723160707.05059311@nx-74205>

  copy mid

https://www.novabbs.com/aus+uk/article-flat.php?id=714&group=uk.comp.os.linux#714

  copy link   Newsgroups: uk.comp.os.linux
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: thoron...@telenet.be (Aragorn)
Newsgroups: uk.comp.os.linux
Subject: Re: Lost in space(s)
Date: Sat, 23 Jul 2022 16:07:07 +0200
Organization: A noiseless patient Strider
Lines: 127
Message-ID: <20220723160707.05059311@nx-74205>
References: <59eeaca9fenoise@audiomisc.co.uk>
<20220723144902.2d890bc7@devuan>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="358f50fa34b601e9b848c05e260b31e0";
logging-data="2397353"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/HQEeKvD56U9HR/3Bogj4J"
Cancel-Lock: sha1:o0B3Q9SQBmK78WdHeWTVHwukdKQ=
X-Newsreader: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu)
 by: Aragorn - Sat, 23 Jul 2022 14:07 UTC

On 23.07.2022 at 14:49, Folderol scribbled:

> On Thu, 26 May 2022 15:23:44 +0100
> Jim Lesurf <noise@audiomisc.co.uk> wrote:
>
> >Personally I regard spaces in file names as a PITA, so never use them
> >myself. But others do and I then have to 'edit' the names at present
> >to avoid the above problem.
>
> Bit late, but is this what you are looking for?
>
> for f in *\ *; do mv "$f" "${f// /_}"; done

That would only work if there is exactly one space in the filename.

I have added two functions to my .bashrc for quickly processing all
files in a directory in both directions. One replaces the spaces with
underscores and the other one does the opposite.

= 8< ==================================================================

spaces2underscores ()
{ targetdir="$*"
if [ ! -z "$1" ]
then
if [ -d "${targetdir}" ]
then
oldpwd=$(pwd)
else
echo "Not a valid directory."
return 2
fi
fi
read -n1 -p "Rename all files in ${targetdir}? [y/N] "
case ${REPLY} in
"Y" | "y" )
if [ -w "${targetdir}" ]
then
cd "${targetdir}"
else
echo
echo "Permission denied."
return 77
fi
fncounter=0
for fn in *
do
newfn=$(printf "${fn}" | tr ' ' '_')
if [ "${newfn}" != "${fn}" ]
then
mv "${fn}" "${newfn}"
fncounter=$((${fncounter}+1))
fi
done
cd "${oldpwd}"
echo
echo "Successfully replaced spaces by underscores in\
${fncounter} filename(s)." echo
;;
* )
echo
echo "Operation aborted."
echo
return 0
;;
esac
unset targetdir oldpwd REPLY fncounter fn newfn
}

underscores2spaces ()
{ targetdir="$*"
if [ ! -z "$1" ]
then
if [ -d "${targetdir}" ]
then
oldpwd=$(pwd)
else
echo "Not a valid directory."
return 2
fi
fi
read -n1 -p "Rename all files in ${targetdir}? [y/N] "
case ${REPLY} in
"Y" | "y" )
if [ -w "${targetdir}" ]
then
cd "${targetdir}"
else
echo
echo "Permission denied."
return 77
fi
fncounter=0
for fn in *
do
newfn=$(printf "${fn}" | tr '_' ' ')
if [ "${newfn}" != "${fn}" ]
then
mv "${fn}" "${newfn}"
fncounter=$((${fncounter}+1))
fi
done
cd "${oldpwd}"
echo
echo "Successfully replaced underscores by spaces in\
${fncounter} filename(s)." echo
;;
* )
echo
echo "Operation aborted."
echo
return 0
;;
esac
unset targetdir oldpwd REPLY fncounter fn newfn
}

export speces2underscores underscores2spaces

--
With respect,
= Aragorn =

Re: Lost in space(s)

<20220723150721.65fb0fd3@devuan>

  copy mid

https://www.novabbs.com/aus+uk/article-flat.php?id=715&group=uk.comp.os.linux#715

  copy link   Newsgroups: uk.comp.os.linux
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: gene...@musically.me.uk (Folderol)
Newsgroups: uk.comp.os.linux
Subject: Re: Lost in space(s)
Date: Sat, 23 Jul 2022 15:07:21 +0100
Organization: A noiseless patient Spider
Lines: 84
Message-ID: <20220723150721.65fb0fd3@devuan>
References: <59eeaca9fenoise@audiomisc.co.uk>
<20220723144902.2d890bc7@devuan>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="9326d5f1cc124a98612a6e7cbf6ccf24";
logging-data="4115265"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/RTf0BezulSoY0tl2InKF01e84YaQf8X8="
Cancel-Lock: sha1:/riVk5IfZJNHnAFmRnMzDKgr38E=
X-Newsreader: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu)
 by: Folderol - Sat, 23 Jul 2022 14:07 UTC

On Sat, 23 Jul 2022 14:49:02 +0100
Folderol <general@musically.me.uk> wrote:

>On Thu, 26 May 2022 15:23:44 +0100
>Jim Lesurf <noise@audiomisc.co.uk> wrote:
>
>>I tend to run ROX-Filer on my Linux machines and then write simple ROX
>>'apps' as a way to carry out various simple routine file-processing tasks.
>>Overall this works fine for me, but in some cases I hit a snag that I don't
>>know how to deal with. The cause is common, so maybe someone here can
>>point out how I can deal with it...
>>
>>For those who don't use it: A Rox 'app' essentially is a directory that
>>contains some specific items the filer uses to tell it is an app, not a
>>plain directory. The entry point is an executable file with the name
>>"AppRun". The contents are read and executed. Typically I use this to
>>contain something like
>>
>>#! /bin/sh
>>
>>exec xterm -fn 10x20 -sb -rightbar -sl 200 -hold -e `dirname $0`/RunImage
>>"$@"
>>
>>(exec command all on one line)
>>
>>This then calls the main code in the file 'RunImage' in the app and runs it
>>in a terminal. The main code I generate from a 'C' program as most of my
>>programming is in 'C'.
>>
>>As you'd expect it executes the RunImage and sends it the context info via
>>the "$@" for the program to get via its 'environment' 'arguments' input. In
>>particular, if I drag-and-drop a file icon onto the app's directory icon
>>ROX runs the app and gives it the full pathname of the file via the above.
>>So the program can find it as an input argument. Thus knows what file I
>>want it to deal with.
>>
>>The snag is when I want to process a file provided by someone else *which
>>contains space characters (or some other 'control' characters)*.
>>
>>e.g. the input file may have a leafname "fred the frog.mkv" rather than
>>"fred_the_frog.mkv".
>>
>>The spaces cause only the initial "fred" to be sent as the input file name.
>>So the RunImage doesn't get the full *actual* name. (the args count remains
>>'2'.)
>>
>>This is presumably because I shouldn't be using "$@" but some other spec
>>that gets the file name sent as a one complete string including the spaces.
>>But my noddy knowledge of bash, etc, means I dunno how to fix this. So can
>>someone explain, please how to get such names sent as a fill file name
>>series of characters. Not split up and lost.
>>
>>Personally I regard spaces in file names as a PITA, so never use them
>>myself. But others do and I then have to 'edit' the names at present to
>>avoid the above problem.
>>
>>BTW if you want to see examples of the ROX apps you can find some here
>>http://www.audiomisc.co.uk/software/index.html
>>mixed in with RISC OS equivalents. Apologies as the programs aren't pretty,
>>I'm not a real programmer, but they get the job done in general.
>>
>>Ta,
>>
>>Jim
>>
>
>Bit late, but is this what you are looking for?
>
>for f in *\ *; do mv "$f" "${f// /_}"; done
>
>

Scratch that!

What is happening is that it is being split up into separate arguments.
You need a loop to scan them all, pick up the text and join them together
with underscores.

Not sure where you go from here. Whatever is actually processing the file needs
to find out the real name.

--
Basic

Re: Lost in space(s)

<20220723161115.14e93775@nx-74205>

  copy mid

https://www.novabbs.com/aus+uk/article-flat.php?id=716&group=uk.comp.os.linux#716

  copy link   Newsgroups: uk.comp.os.linux
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: thoron...@telenet.be (Aragorn)
Newsgroups: uk.comp.os.linux
Subject: Re: Lost in space(s)
Date: Sat, 23 Jul 2022 16:11:15 +0200
Organization: A noiseless patient Strider
Lines: 14
Message-ID: <20220723161115.14e93775@nx-74205>
References: <59eeaca9fenoise@audiomisc.co.uk>
<20220723144902.2d890bc7@devuan>
<20220723160707.05059311@nx-74205>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="358f50fa34b601e9b848c05e260b31e0";
logging-data="2397353"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GGw40k2tRVCgzWJF0V0lV"
Cancel-Lock: sha1:vYzj5hp/fA/DcNI8NuyWQ+9cLn4=
X-Newsreader: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu)
 by: Aragorn - Sat, 23 Jul 2022 14:11 UTC

On 23.07.2022 at 16:07, Aragorn scribbled:

> echo "Successfully replaced spaces by underscores in\
> ${fncounter} filename(s)." echo
> ;;

My apologies for the way my newsreader garbled that. That last "echo"
command should of course go on a new line.

--
With respect,
= Aragorn =

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor