passing arguments to system command
Brian K. White
brian at aljex.com
Thu Oct 5 11:25:05 PDT 2017
On 10/3/2017 1:45 PM, scooter6--- via Filepro-list wrote:
> Hmm..not how I would have ever thought to do that... currently I pass
> <aa<ab<ac, etc......I would have assumed then I would have needed
> <"\"{ac{"\" ? But that didn't work...
> I'll give this a try....thanks Mark
To make a system command, all you are doing is assembling a string, no
different than assigning a variable or displaying a msgbox. You can
assemble the string any number of different ways. Your way works too,
you just left out a couple quotes.
You said
<"\"{ac{"\"
You forgot to think of the \" as a single entity.
Pretend \" is just x, and write that same line:
<"x{ac{"x
And now you probably see what was wrong with the line.
That would need to be:
<"x"{ac{"x"
Now replace x with \" again and you get:
<"\""{ac{"\""
So you could put all the literals and escaped quotes in the system
command directly:
system "command arg1 \"arg 2\" arg3"
You could do your way, which is putting the args into variables, and
then adding quotes to one of those variables on the system command line.
That would look like this:
system aa < "\""{bb{"\"" < cc
Or you could put a quote mark into a variable to make the system
commands slightly simpler to read:
q = "\""
system aa < q{bb{q < cc
Or you could include the quotes in the variable, and then your original
system command that you had before adding any spaces would stay the same:
bb = "\"string with spaces\""
or
bb = "\"Notice from" < control(1) < ", invoice #" < 1 { "\""
or you have bb already being assigned somewhere else by whatever means,
and later you just want to add quotes to it at the end just before using it:
bb = "\"" { bb { "\""
And your system command remains your original with no change at all:
system aa < bb < cc
Myself, I usually like to build up a single variable like in Marks
example, because it makes it convenient to develop, and later debug the
command by just replacing "system" with "msgbox"
Often my system commands are actually a few commands together, so I
usually use roughly
s = "command 1"
s = s < ";command 2"
s = s < ";command 3"
and each command might have it's own building-up
s = s < ";command < aa < "\"" { bb { "\"" < cc
and say my code branches all over the place and I have no idea if I
built a sensible command by the end...
msgbox s
'system s
ok looks ok
'msgbox s
system s
--
bkw
> On Tue, Oct 3, 2017 at 1:06 PM, Fairlight via Filepro-list <
> filepro-list at lists.celestial.com> wrote:
>
>> aa = "/path/to/command" < "arg1" < "\"arg2 with spaces\"" < "arg3"
>> system aa
>>
>> mark->
>>
>> On Tue, Oct 03, 2017 at 12:56:39PM -0400, scooter6--- via Filepro-list
>> thus spoke:
>>> I have a process that triggers an email at the end and I pass several
>>> variables to my shell script
>>> All of these parameters are short and contain no spaces....
>>>
>>> How do I character escape a string I want to send my script that would
>> have
>>> spaces in it?
>>> Meaning how would I send literal " (quotes) around a longer variable that
>>> has spaces in it?
>>>
>>>
>>> thanks
>>>
>>> Scott
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL: <http://mailman.celestial.com/pipermail/filepro-list/
>> attachments/20171003/4e49eb59/attachment.html>
>>> _______________________________________________
>>> Filepro-list mailing list
>>> Filepro-list at lists.celestial.com
>>> Subscribe/Unsubscribe/Subscription Changes
>>> http://mailman.celestial.com/mailman/listinfo/filepro-list
>>>
>>
>> --
>> Audio panton, cogito singularis.
>> _______________________________________________
>> Filepro-list mailing list
>> Filepro-list at lists.celestial.com
>> Subscribe/Unsubscribe/Subscription Changes
>> http://mailman.celestial.com/mailman/listinfo/filepro-list
>>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mailman.celestial.com/pipermail/filepro-list/attachments/20171003/ef84d34f/attachment.html>
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> http://mailman.celestial.com/mailman/listinfo/filepro-list
>
More information about the Filepro-list
mailing list