Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Everyone is entitled to an *informed* opinion." -- Harlan Ellison


devel / comp.unix.shell / Re: Correct quoting through several levels of tools (shell, expect, ftp)

SubjectAuthor
* Correct quoting through several levels of tools (shell, expect, ftp)Janis Papanagnou
+* Re: Correct quoting through several levels of tools (shell, expect,Chris Elvidge
|+- Re: Correct quoting through several levels of tools (shell, expect,Chris Elvidge
|`- Re: Correct quoting through several levels of tools (shell, expect,Janis Papanagnou
+- Re: Correct quoting through several levels of tools (shell, expect,Chris Elvidge
+* Re: Correct quoting through several levels of tools (shell, expect, ftp)Kenny McCormack
|+* Re: Correct quoting through several levels of tools (shell, expect, ftp)Andreas Eder
||`- Re: Correct quoting through several levels of tools (shell, expect, ftp)Kenny McCormack
|`- Re: Correct quoting through several levels of tools (shell, expect,Janis Papanagnou
`* Re: Correct quoting through several levels of tools (shell, expect,Ed Morton
 `* Re: Correct quoting through several levels of tools (shell, expect,Janis Papanagnou
  `* Re: Correct quoting through several levels of tools (shell, expect,Kenny McCormack
   `- Re: Correct quoting through several levels of tools (shell, expect,Janis Papanagnou

1
Correct quoting through several levels of tools (shell, expect, ftp)

<st1jn9$poc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4934&group=comp.unix.shell#4934

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Correct quoting through several levels of tools (shell, expect, ftp)
Date: Fri, 28 Jan 2022 21:29:29 +0100
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <st1jn9$poc$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 28 Jan 2022 20:29:29 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a27091d8f8e607aa7775e632f38e8d95";
logging-data="26380"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+g+0NiIswJTey1MJk3L2i"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:6LyrqsyfHRfzLnIYE5jFsgQ+jYw=
X-Mozilla-News-Host: news://news.eternal-september.org:119
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 28 Jan 2022 20:29 UTC

I have a shell script like the one depicted below as excerpt to invoke
simple ftp-transfers; the script invokes expect, and expect spawns ftp.
That script has issues with (today common) pathological file names.

How would the correct quoting be done to pass the file with the below
depicted filename through all these nested tools?

server=...
file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'
....
expect <<EOT
spawn ftp -i "${server}"
....
expect "ftp> "
send "put ${file}\r"
....
EOT

Janis

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<st1rau$dvk$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4935&group=comp.unix.shell#4935

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chr...@mshome.net (Chris Elvidge)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect,
ftp)
Date: Fri, 28 Jan 2022 22:39:08 +0000
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <st1rau$dvk$1@dont-email.me>
References: <st1jn9$poc$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 28 Jan 2022 22:39:26 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e45b5f12aea42d257804c7f08c3c9b19";
logging-data="14324"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184KtsMRyVaOqdKK5471MGalh6nAce1Gvs="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:xXJPovTtOq9g5YqSMC8A4miOzSE=
In-Reply-To: <st1jn9$poc$1@dont-email.me>
Content-Language: en-GB
 by: Chris Elvidge - Fri, 28 Jan 2022 22:39 UTC

On 28/01/2022 20:29, Janis Papanagnou wrote:
> I have a shell script like the one depicted below as excerpt to invoke
> simple ftp-transfers; the script invokes expect, and expect spawns ftp.
> That script has issues with (today common) pathological file names.
>
> How would the correct quoting be done to pass the file with the below
> depicted filename through all these nested tools?
>
>
> server=...
> file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'
> ...
> expect <<EOT
> spawn ftp -i "${server}"
> ...
> expect "ftp> "
> send "put ${file}\r"
> ...
> EOT
>
>
> Janis
>

$file contains an illegal character (/) perhaps?

Why are you using expect?

ftp -niv $HOST <<EOT
$USER
$PWD
put $FILE
quit

seems to work.

--
Chris Elvidge
England

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<st1rfc$dvk$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4936&group=comp.unix.shell#4936

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chr...@mshome.net (Chris Elvidge)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect,
ftp)
Date: Fri, 28 Jan 2022 22:41:48 +0000
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <st1rfc$dvk$2@dont-email.me>
References: <st1jn9$poc$1@dont-email.me> <st1rau$dvk$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 28 Jan 2022 22:41:49 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e45b5f12aea42d257804c7f08c3c9b19";
logging-data="14324"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jsMhMk3rcd10HAeWEUCVQ97TZXJYb6jU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:vZ0uFvWEGkHYpOBsMW1n3xo94Oo=
In-Reply-To: <st1rau$dvk$1@dont-email.me>
Content-Language: en-GB
 by: Chris Elvidge - Fri, 28 Jan 2022 22:41 UTC

On 28/01/2022 22:39, Chris Elvidge wrote:
> On 28/01/2022 20:29, Janis Papanagnou wrote:
>> I have a shell script like the one depicted below as excerpt to invoke
>> simple ftp-transfers; the script invokes expect, and expect spawns ftp.
>> That script has issues with (today common) pathological file names.
>>
>> How would the correct quoting be done to pass the file with the below
>> depicted filename through all these nested tools?
>>
>>
>> server=...
>> file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'
>> ...
>> expect <<EOT
>> spawn ftp -i "${server}"
>> ...
>> expect "ftp> "
>> send "put ${file}\r"
>> ...
>> EOT
>>
>>
>> Janis
>>
>
> $file contains an illegal character (/) perhaps?
>
> Why are you using expect?
>
> ftp -niv $HOST <<EOT
> $USER
> $PWD
> put $FILE
> quit
>
> seems to work.
>
Sorry forgot the EOT after quit.

--
Chris Elvidge
England

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<st1s3h$iif$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4937&group=comp.unix.shell#4937

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chr...@mshome.net (Chris Elvidge)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect,
ftp)
Date: Fri, 28 Jan 2022 22:52:16 +0000
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <st1s3h$iif$1@dont-email.me>
References: <st1jn9$poc$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 28 Jan 2022 22:52:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e45b5f12aea42d257804c7f08c3c9b19";
logging-data="19023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/P7VVfErB7wdeJThXjObKgERqZFK0VjG8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:+i3OybgWoXlPtSlegUdwO3oyekg=
In-Reply-To: <st1jn9$poc$1@dont-email.me>
Content-Language: en-GB
 by: Chris Elvidge - Fri, 28 Jan 2022 22:52 UTC

On 28/01/2022 20:29, Janis Papanagnou wrote:
> I have a shell script like the one depicted below as excerpt to invoke
> simple ftp-transfers; the script invokes expect, and expect spawns ftp.
> That script has issues with (today common) pathological file names.
>
> How would the correct quoting be done to pass the file with the below
> depicted filename through all these nested tools?
>
>
> server=...
> file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'
> ...
> expect <<EOT
> spawn ftp -i "${server}"
> ...
> expect "ftp> "
> send "put ${file}\r"
> ...
> EOT
>
>
> Janis
>

Sorry, please disregard suggestion (except / in filename)

--
Chris Elvidge
England

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<st2u3b$u21$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4938&group=comp.unix.shell#4938

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect,
ftp)
Date: Sat, 29 Jan 2022 09:32:42 +0100
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <st2u3b$u21$1@dont-email.me>
References: <st1jn9$poc$1@dont-email.me> <st1rau$dvk$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 Jan 2022 08:32:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="62d2bdc1b12ea631faba845f06c33429";
logging-data="30785"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/UQs7w+o+YSLw244NJ93iH"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:72tEAk+dxvKQomOaZxQXDxQnqX8=
In-Reply-To: <st1rau$dvk$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 29 Jan 2022 08:32 UTC

On 28.01.2022 23:39, Chris Elvidge wrote:
> On 28/01/2022 20:29, Janis Papanagnou wrote:
>> I have a shell script like the one depicted below as excerpt to invoke
>> simple ftp-transfers; the script invokes expect, and expect spawns ftp.
>> That script has issues with (today common) pathological file names.
>>
>> How would the correct quoting be done to pass the file with the below
>> depicted filename through all these nested tools?
>>
>>
>> server=...
>> file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'
>> ...
>> expect <<EOT
>> spawn ftp -i "${server}"
>> ...
>> expect "ftp> "
>> send "put ${file}\r"
>> ...
>> EOT
>>
>>
>> Janis
>>
>
> $file contains an illegal character (/) perhaps?

My fault; for posting purposes I made up a long file name and wanted
to abbreviate "with" with "w/", missing that this would change the
filename semantics. The actual filenames have blanks and parenthesis,
but no '/', '\', '\\' or other Unix/DOS directory separators.

>
> Why are you using expect?

When I wrote it ftp seemed to only support an interactive mode, so
I had to implement the question/answer protocol; the quasi-standard
tool for such tasks was expect.

>
> ftp -niv $HOST <<EOT
> $USER
> $PWD
> put $FILE
> quit
>
> seems to work.

I haven't tried it but I saw your other post "Sorry, please disregard
suggestion", and suppose you meant this one actually doesn't work?

Nevermind, I inspected per "apropos ftp" available programs and found
ncftpget and ncftpput. Yet I haven't tried them but they might serve
the tasks I have. Only thing I don't see in the man page is that there
seems to be no equivalent to mput/mget for the transfer of many files
available. (I'll have to see.) Avoiding the multiple authentications
with its delay in case of multiple file transfers would be desirable.

Besides this (potential) alternative I'd nonetheless be curious about
insights with regard of my original question; correct quoting through
several levels of these tools (in case I'll need it at times, or have
to resort to that approach).

Thanks.

Janis

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<st3d2k$3pbub$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4940&group=comp.unix.shell#4940

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect, ftp)
Date: Sat, 29 Jan 2022 12:48:20 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <st3d2k$3pbub$1@news.xmission.com>
References: <st1jn9$poc$1@dont-email.me>
Injection-Date: Sat, 29 Jan 2022 12:48:20 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3977163"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sat, 29 Jan 2022 12:48 UTC

In article <st1jn9$poc$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>I have a shell script like the one depicted below as excerpt to invoke
>simple ftp-transfers; the script invokes expect, and expect spawns ftp.
>That script has issues with (today common) pathological file names.
>
>How would the correct quoting be done to pass the file with the below
>depicted filename through all these nested tools?
>
>
>server=...
>file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'
>...
>expect <<EOT
>spawn ftp -i "${server}"
>...
>expect "ftp> "
>send "put ${file}\r"
>...
>EOT

There are basically 3 ways to "script" FTP transfers:

1) Directly. By this, I mean by supplying the actual FTP commands on stdin
and/or writing them to a file, then invoking FTP with some silly options to
get it to run in script mode. Most of the answers so far on this thread
have been in this category. I find this method hinky and try to avoid it
if at all possible.

2) Using Expect. This is the method I'm most comfortable with, and I
encourage you to stay with it. I would do it more like this, though:

#!/usr/bin/expect --
spawn ftp [lindex $argv 0]
....
expect "ftp> "
send "put [lindex $argv 1]\r"
....

Then I would call that script passing the server and the filename as
command line args. Note that in all my years of Expect scripting, I never
figured out a way to access the command line args (In Expect/TCL-speak,
$argv) from a command line (-c 'Expect Script Here') Expect program. It
only seems to work when the script is in a file. I am open to suggestions
about how to do that.

Note, BTW, that I *think* what you did originally would/should work if you
had used "-c" to pass the Expect script on the command line, rather than
feeding the script in via stdin.

3) Using some other command line tool that is designed for automating FTP
transfers. I've used ncftpget/ncftpput in the past; there are more
current versions of the general concept now, like "curl" and "iftp" and so
on. These all seem to work well, and I've nothing bad to say about them.

Finally, note that the oft-given-advice at this point is to not use FTP
since it is "insecure". The kewl people nowadays all use ssh/scp or some
variant thereof. Any particular reason you aren't doing that too? Any
reason you don't want all your friends to think you're kewl?

--
Faced with the choice between changing one's mind and proving that there is
no need to do so, almost everyone gets busy on the proof.

- John Kenneth Galbraith -

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<87ee4qit7q.fsf@eder.anydns.info>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4941&group=comp.unix.shell#4941

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: a_eder_...@web.de (Andreas Eder)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect, ftp)
Date: Sat, 29 Jan 2022 14:09:45 +0100
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <87ee4qit7q.fsf@eder.anydns.info>
References: <st1jn9$poc$1@dont-email.me> <st3d2k$3pbub$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="37c1c4e8081ce595185e5d0d13bf5b22";
logging-data="15270"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xecsKFD7nJ7OKI0BIffcq"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:bwGBLXtkqJGvGGsnhASGk+zY1dM=
sha1:1CmWAk9gspHTjLi0dhrjuQNz8vs=
 by: Andreas Eder - Sat, 29 Jan 2022 13:09 UTC

On Sa 29 Jan 2022 at 12:48, gazelle@shell.xmission.com (Kenny McCormack) wrote:

> 3) Using some other command line tool that is designed for automating FTP
> transfers. I've used ncftpget/ncftpput in the past; there are more
> current versions of the general concept now, like "curl" and "iftp" and so
> on. These all seem to work well, and I've nothing bad to say about them.

There is also lftp which works quite well with scripts.

'Andreas

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<st3esj$gio$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4942&group=comp.unix.shell#4942

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect,
ftp)
Date: Sat, 29 Jan 2022 07:19:14 -0600
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <st3esj$gio$1@dont-email.me>
References: <st1jn9$poc$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 Jan 2022 13:19:15 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e308f083d266d7ce7fc99d1002ad7f6a";
logging-data="16984"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MMoGGI0E74Wef+m627uHu"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:2MAb2cmQ9lNvShJkDSLkem+oxqA=
In-Reply-To: <st1jn9$poc$1@dont-email.me>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 220129-0, 1/28/2022), Outbound message
 by: Ed Morton - Sat, 29 Jan 2022 13:19 UTC

On 1/28/2022 2:29 PM, Janis Papanagnou wrote:
> I have a shell script like the one depicted below as excerpt to invoke
> simple ftp-transfers; the script invokes expect, and expect spawns ftp.
> That script has issues with (today common) pathological file names.
>
> How would the correct quoting be done to pass the file with the below
> depicted filename through all these nested tools?
>
>
> server=...
> file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'

Does updating it with printf '%q` get you to where you need to be:

$ file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'
$ printf -v file '%q' "$file"
$ echo "$file"
A\ \(pathological\)\ file\ name\ w/\ blanks\,\ parenthesis\,\ etc.pdf

Ed.

> ...
> expect <<EOT
> spawn ftp -i "${server}"
> ...
> expect "ftp> "
> send "put ${file}\r"
> ...
> EOT
>
>
> Janis

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<st3hmh$3pd67$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4943&group=comp.unix.shell#4943

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect, ftp)
Date: Sat, 29 Jan 2022 14:07:13 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <st3hmh$3pd67$1@news.xmission.com>
References: <st1jn9$poc$1@dont-email.me> <st3d2k$3pbub$1@news.xmission.com> <87ee4qit7q.fsf@eder.anydns.info>
Injection-Date: Sat, 29 Jan 2022 14:07:13 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3978439"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sat, 29 Jan 2022 14:07 UTC

In article <87ee4qit7q.fsf@eder.anydns.info>,
Andreas Eder <a_eder_muc@web.de> wrote:
>On Sa 29 Jan 2022 at 12:48, gazelle@shell.xmission.com (Kenny McCormack) wrote:
>
>> 3) Using some other command line tool that is designed for automating FTP
>> transfers. I've used ncftpget/ncftpput in the past; there are more
>> current versions of the general concept now, like "curl" and "iftp" and so
>> on. These all seem to work well, and I've nothing bad to say about them.
>
>There is also lftp which works quite well with scripts.

I think I meant to say 'lftp' when I said 'iftp'.

--
"I think I understand delicate, but why do I have to wash my hands, and
be standing in cold water when doing it?"

Kaz Kylheku <kaz@kylheku.com> in comp.lang.c

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<st4b4h$3oq$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4944&group=comp.unix.shell#4944

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect,
ftp)
Date: Sat, 29 Jan 2022 22:21:20 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <st4b4h$3oq$1@dont-email.me>
References: <st1jn9$poc$1@dont-email.me> <st3d2k$3pbub$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 Jan 2022 21:21:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="36ba61003b5be6877149b25fbbca8c62";
logging-data="3866"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FuqKcdzO3ywp0iyRenhPu"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:9UXZrppnyD+JdcIYaEOrsCyEld0=
In-Reply-To: <st3d2k$3pbub$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 29 Jan 2022 21:21 UTC

Thanks for your suggestions. At the moment just a quick response to this
question...

On 29.01.2022 13:48, Kenny McCormack wrote:
>
> Finally, note that the oft-given-advice at this point is to not use FTP
> since it is "insecure". The kewl people nowadays all use ssh/scp or some
> variant thereof. Any particular reason you aren't doing that too? Any
> reason you don't want all your friends to think you're kewl?

The reasons are quite mundane; ftp is primitive, it's the one I know,
no unnecessary complexity (remember my email-crypt-issue in another
thread), and it's only for transfers I do locally between different
devices at home.

What other folks think concerning my kewlness or whatnot isn't a theme
where I spend any neurons for.

Janis

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<st4biv$7af$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4945&group=comp.unix.shell#4945

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect,
ftp)
Date: Sat, 29 Jan 2022 22:29:02 +0100
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <st4biv$7af$1@dont-email.me>
References: <st1jn9$poc$1@dont-email.me> <st3esj$gio$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 Jan 2022 21:29:03 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="36ba61003b5be6877149b25fbbca8c62";
logging-data="7503"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19i/86m818c0HFbPJ4se4PC"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:qBdLkgU5OnS6MwbViz32M2gRoX4=
In-Reply-To: <st3esj$gio$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 29 Jan 2022 21:29 UTC

On 29.01.2022 14:19, Ed Morton wrote:
> On 1/28/2022 2:29 PM, Janis Papanagnou wrote:
>> I have a shell script like the one depicted below as excerpt to invoke
>> simple ftp-transfers; the script invokes expect, and expect spawns ftp.
>> That script has issues with (today common) pathological file names.
>>
>> How would the correct quoting be done to pass the file with the below
>> depicted filename through all these nested tools?
>>
>>
>> server=...
>> file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'
>
> Does updating it with printf '%q` get you to where you need to be:

There's different ways of quoting. What I already tried had been

file=$(quote "${file}")

where quote replaces the value by the single quoted value (as opposed
to escapes of individual characters). But no, it didn't help here.

>
> $ file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'
> $ printf -v file '%q' "$file"

Unlike bash's, my printf has no -v, just BTW.

Janis

> $ echo "$file"
> A\ \(pathological\)\ file\ name\ w/\ blanks\,\ parenthesis\,\ etc.pdf
>
> Ed.

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<st51ro$3q6lu$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4946&group=comp.unix.shell#4946

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect,
ftp)
Date: Sun, 30 Jan 2022 03:49:12 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <st51ro$3q6lu$1@news.xmission.com>
References: <st1jn9$poc$1@dont-email.me> <st3esj$gio$1@dont-email.me> <st4biv$7af$1@dont-email.me>
Injection-Date: Sun, 30 Jan 2022 03:49:12 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="4004542"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sun, 30 Jan 2022 03:49 UTC

In article <st4biv$7af$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
....
>> $ file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'
>> $ printf -v file '%q' "$file"
>
>Unlike bash's, my (I.e., ksh's) printf has no -v, just BTW.

Isn't -v just a shorthand for:

var=$(printf ...)

?

So, you would just use that instead.

What about %q? Does ksh have that? That also might be bash-specific -
but I don't know for sure...

--
The coronavirus is the first thing, in his 74 pathetic years of existence,
that the orange menace has come into contact with, that he couldn't browbeat,
bully, bullshit, bribe, sue, legally harrass, get Daddy to fix, get his
siblings to bail him out of, or, if all else fails, simply wish it away.

Re: Correct quoting through several levels of tools (shell, expect, ftp)

<st5od4$4b5$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4947&group=comp.unix.shell#4947

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Correct quoting through several levels of tools (shell, expect,
ftp)
Date: Sun, 30 Jan 2022 11:13:55 +0100
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <st5od4$4b5$1@dont-email.me>
References: <st1jn9$poc$1@dont-email.me> <st3esj$gio$1@dont-email.me>
<st4biv$7af$1@dont-email.me> <st51ro$3q6lu$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 30 Jan 2022 10:13:56 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d1924d35a3eba220980b5a034568ca34";
logging-data="4453"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+0b2SIaP6YMHj7SxaBS74j"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:+cnJPXtBcK+TMo6rH/7YWwxjmtM=
In-Reply-To: <st51ro$3q6lu$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sun, 30 Jan 2022 10:13 UTC

On 30.01.2022 04:49, Kenny McCormack wrote:
> In article <st4biv$7af$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> ...
>>> $ file='A (pathological) file name w/ blanks, parenthesis, etc.pdf'
>>> $ printf -v file '%q' "$file"
>>
>> Unlike bash's, my (I.e., ksh's) printf has no -v, just BTW.
>
> Isn't -v just a shorthand for:
>
> var=$(printf ...)

Effectively (maybe) yes, but I wouldn't bet on it, since the
subshell context or command composition may have side effects
that direct variable setting wouldn't have. (No coffee yet,
so I'm doing hard at the moment to think about samples, but I
think it's not bad to have a simple -v assignment available.)
Given that 'printf' is a builtin and $(...) of that builtin
will [in ksh] not create an extra process it's also not slow.

>
> ?
>
> So, you would just use that instead.

That's how we can do it with shells not supporting printf -v.
(The wrapper I used is effectively also just a printf, doing
var=$(quote ...), but consistently for all arguments not only
for those that need it in shell contexts.)

>
> What about %q? Does ksh have that? That also might be bash-specific -
> but I don't know for sure...

The %q is also in Ksh's printf. Beyond the ANSI specifiers, Ksh
supports %b %B %H %P %R %T %Z and %({csv|html|ere|pattern|url})q .
A couple of these are quite noteworthy - I don't know what bash
supports -, e.g. pattern conversions, CSV, HTML, URL conversions,
time formatting. There's also format modifiers to consider width
for characters instead of bytes/octets, and new ANSI escapes for
Unicode characters, scaling factors (1000 and 1024 based), digit
grouping, and a lot more.

Janis

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor