[Lazarus] Command line interpretation on Linux console program...

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Command line interpretation on Linux console program...

Free Pascal - Lazarus mailing list
I have a project where I am creatinmg a video splitting utility using
FPC 3.0.4 and Lazarus 2.0.0 calling ffmpeg via RunCommandIndir()
defined in the Process library unit.

The project contains both a GUI and a command line version of the
utility, so all manipulation functions are contained in a separate
unit used by both versions and both Windows and Linux.
I have a strange problem with the command line utility...

When I try to debug it there are two different, but possibly related
problems:

1) When I enter a file name as ~/Videos/input.mp4 then FileExists()
reports that the file does not exist even though I can clearly see it.
If I instead use /home/user/Videos/input.mp4 then it will see it
properly. Same if I use the syntax ./filename.mp4 when the file is in
the current dir.
Why does FileExists() not recognize ~ as shorthand for the home dir?
It is rather inconvenient to be forced to use the longer paths...

2) Another issue concerns the parsing of command line parameters.
Originally I had set it up to use ; as separator for the two time
values of a clip, starttime and duration (in seconds) as follows:
t1234;500 for a duration 500 s clip starting at 1234 s into the source
video.
But for some reason the ParamCount variable contains 3 when the
command line looks like this:

videosplitcmb -x -iorg.mp4 -t0;1768 -t2420;2972 -otest4.mp4

There should really be 5 parameters: -t, -i, -t, -t, -o

Why is ; treated as some kind of block for the command line parsing?

I have had to temporarily replace ; with _ in order to test my
program...


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Command line interpretation on Linux console program...

Free Pascal - Lazarus mailing list
On 11/04/2019 22.03, Bo Berglund via lazarus wrote:

> 2) Another issue concerns the parsing of command line parameters.
> Originally I had set it up to use ; as separator for the two time
> values of a clip, starttime and duration (in seconds) as follows:
> t1234;500 for a duration 500 s clip starting at 1234 s into the source
> video.
> But for some reason the ParamCount variable contains 3 when the
> command line looks like this:
>
> videosplitcmb -x -iorg.mp4 -t0;1768 -t2420;2972 -otest4.mp4
>
> There should really be 5 parameters: -t, -i, -t, -t, -o
>
> Why is ; treated as some kind of block for the command line parsing?
Bash also stops at the ';', it is a command separator. It is like
entering two commands like this:

videosplitcmb -x -iorg.mp4 -t0
1768 -t2420;2972 -otest4.mp4

You have to escape the ';', like this: '\;'


In fact, if "videosplitcmb" is your program, it doesn't even see the
second part, it is bash who stops at the ";" before calling "videosplitcmb".

--
Cheers / Saludos,

                Carlos E. R.
                (from 15.0 x86_64 at Telcontar)


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Command line interpretation on Linux console program...

Free Pascal - Lazarus mailing list
On Thu, 11 Apr 2019 22:30:44 +0200, "Carlos E. R. via lazarus"
<[hidden email]> wrote:

>In fact, if "videosplitcmb" is your program, it doesn't even see the
>second part, it is bash who stops at the ";" before calling "videosplitcmb".

Thanks,
rather than taking on Linux I changed the separator to comma since the
values are numeric whole seconds so a decimal separator would not come
into play anyway..
Works fine...


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Command line interpretation on Linux console program...

Free Pascal - Lazarus mailing list
On 11/04/2019 23.40, Bo Berglund via lazarus wrote:

> On Thu, 11 Apr 2019 22:30:44 +0200, "Carlos E. R. via lazarus"
> <[hidden email]> wrote:
>
>> In fact, if "videosplitcmb" is your program, it doesn't even see the
>> second part, it is bash who stops at the ";" before calling "videosplitcmb".
>
> Thanks,
> rather than taking on Linux I changed the separator to comma since the
> values are numeric whole seconds so a decimal separator would not come
> into play anyway..
> Works fine...
That assumes that you will never operate that program on different
languages than yours, because, for instance, here the decimal separator
is a comma.

--
Cheers / Saludos,

                Carlos E. R.
                (from 15.0 x86_64 at Telcontar)


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Command line interpretation on Linux console program...

Free Pascal - Lazarus mailing list
On 4/11/19 9:49 PM, Carlos E. R. via lazarus wrote:
> That assumes that you will never operate that program on different
> languages than yours, because, for instance, here the decimal separator
> is a comma.


not for *whole* seconds ;)


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list unless*
        *a signed and pre-paid contract is in effect with us.*
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Command line interpretation on Linux console program...

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
Op 2019-04-11 om 22:03 schreef Bo Berglund via lazarus:
>  
> 1) When I enter a file name as ~/Videos/input.mp4 then FileExists()
> reports that the file does not exist even though I can clearly see it.
> If I instead use /home/user/Videos/input.mp4 then it will see it
> properly. Same if I use the syntax ./filename.mp4 when the file is in
> the current dir.
> Why does FileExists() not recognize ~ as shorthand for the home dir?
> It is rather inconvenient to be forced to use the longer paths...

Because expanding ~ happens on the shell level, and programs usually
don't see it (they get their parameters already substituted). If they
use ~ and other shell modifiers themselves, e.g. in configuration, it is
the programmer's responsibility to do substitutions he likes to support.

> 2) Another issue concerns the parsing of command line parameters.
> Originally I had set it up to use ; as separator for the two time
> values of a clip, starttime and duration (in seconds) as follows:
> t1234;500 for a duration 500 s clip starting at 1234 s into the source
> video.
> But for some reason the ParamCount variable contains 3 when the
> command line looks like this:

Here also, the shell does parameter separation on *nix, and the program
receives an array.


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Command line interpretation on Linux console program...

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On Fri, 12 Apr 2019 03:49:36 +0200, "Carlos E. R. via lazarus"
<[hidden email]> wrote:

>
>That assumes that you will never operate that program on different
>languages than yours, because, for instance, here the decimal separator
>is a comma.

I am in Sweden where we use comma as decimal separator and this is why
I wrote my comment about the integer seconds needing no decimals.


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Command line interpretation on Linux console program...

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On Thu, 11 Apr 2019 22:03:55 +0200, Bo Berglund via lazarus
<[hidden email]> wrote:

>I have a project where I am creatinmg a video splitting utility using
>FPC 3.0.4 and Lazarus 2.0.0 calling ffmpeg via RunCommandIndir()
>defined in the Process library unit.

A project related question for the command line utility:
--------------------------------------------------------
I have enabled the addition of version information in Project
properties (just version info, no icon).
So I filled it all in and hit OK then used Run/build to create the
executable.

Now my question is this:
How can I inspect the program file and verify that the version info is
actually included?
My development machine is a Linux Mint 19 virtual computer under
VMWare Workstation PRO15.
I used the system file browser (named Caja) and navigated to the file,
right clicked and selected properties. But nothing showed up regarding
my info.
So how can I see what was entered as version info?
In Delphi it used to be that you had to do a build to stuff it into
the executable. So I have used Run/build to create it.


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus