[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to change directory of work?


Le 13/04/2025 à 23:18, Bruce Steers a écrit :

On Sun, 13 Apr 2025 at 21:28, <roberto.premoli@xxxxxxxxxx <mailto:roberto.premoli@xxxxxxxxxx>> wrote:

    __

    hello.
    im writing a frontend with gambas to a program (no matter it now), lets call it "executable_cli".
    This program is in /somewhere/path/to/program, in my case: "/home/user/path/to/program"

    so i use

    shell "/home/user/path/to/program"

    I do what i do into executable_ci, close it and back to frontend. all good till now.

    But the executable_cli suppose to find and save data in his current directory that is /home/user/path/to/program but frontend current directory is /home/user

    executable_chi cannot be parametrized with some flag to tell hime where save data and from where retrive data, it supposes always tht place is here it is in the filesystem and I cannot change the executable behaviour.

    so, from gambas, i try to do:

    shell "cd /home/user/path/to/program"
    shell "/home/user/path/to/program/executable_cli"

    but i does not work

    exec ["cd /home/user/path/to/program"] does not work either.

    so, who to tell gambas to "move into" /somewhere/path/to/program?


    Thanks
Roberto

there is no such thing as a "working directory" in gambas.

every time you run Shell you create a new process so you cannot run "cd dir" in one Shell command then another Shell command be in that dir.

You could do it in one single Shell command by using a newline..

Shell "cd /home/user/path/to/program\n" &
       "executable_cli"

But you cannot change the applications working directory.

BruceS


Otherwise you can actually specify the working directory in Exec or Shell by specifying it the "PWD" environment variable.

Exec ["pwd"] With ["PWD=/root"] Wait

It's an undocumented Gambas feature.

Regards,

--
Benoît Minisini.


Follow-Ups:
Re: how to change directory of work?T Lee Davidson <t.lee.davidson@xxxxxxxxx>
References:
how to change directory of work?roberto.premoli@xxxxxxxxxx
Re: how to change directory of work?Bruce Steers <bsteers4@xxxxxxxxx>