How to execute command installed with snap
-
wrote on 23 Aug 2023, 20:12 last edited by Stormbringer1900
On Ubuntu 20.04, when I try to execute something like :
QProcess::execute("lpr ...");
or
system("lpr ...");
That reply :
lpr command not found.
In gnome-terminal, the command lpr exists and "whereis lpr" reply in "/usr/bin"
If I try
QProcess::execute("whereis lpr");
there's no reply.No problem. I try this command :
ls -l /usr/bin
With gnome-terminale, I found a lot of files and lpr, lp and somes others files depending of snap installations.
With QProcess and system, nothing from snap is present.
Do you know why and what is the good way to execute a command installed by snap with QProcess or system, please ?
-
On Ubuntu 20.04, when I try to execute something like :
QProcess::execute("lpr ...");
or
system("lpr ...");
That reply :
lpr command not found.
In gnome-terminal, the command lpr exists and "whereis lpr" reply in "/usr/bin"
If I try
QProcess::execute("whereis lpr");
there's no reply.No problem. I try this command :
ls -l /usr/bin
With gnome-terminale, I found a lot of files and lpr, lp and somes others files depending of snap installations.
With QProcess and system, nothing from snap is present.
Do you know why and what is the good way to execute a command installed by snap with QProcess or system, please ?
wrote on 23 Aug 2023, 20:19 last edited by JoeCFD@Stormbringer1900 you add the full path to it
QProcess::execute("/usr/bin/lpr", QStringList() );QStringList arguments = { "lpr" };
QProcess::execute("/usr/bin/lwhereis", arguments ); -
On Ubuntu 20.04, when I try to execute something like :
QProcess::execute("lpr ...");
or
system("lpr ...");
That reply :
lpr command not found.
In gnome-terminal, the command lpr exists and "whereis lpr" reply in "/usr/bin"
If I try
QProcess::execute("whereis lpr");
there's no reply.No problem. I try this command :
ls -l /usr/bin
With gnome-terminale, I found a lot of files and lpr, lp and somes others files depending of snap installations.
With QProcess and system, nothing from snap is present.
Do you know why and what is the good way to execute a command installed by snap with QProcess or system, please ?
wrote on 23 Aug 2023, 20:38 last edited by@Stormbringer1900
Your snaps ought be in/snap/bin
. You might want to put that on yourPATH
. Does that alter the behaviour? -
On Ubuntu 20.04, when I try to execute something like :
QProcess::execute("lpr ...");
or
system("lpr ...");
That reply :
lpr command not found.
In gnome-terminal, the command lpr exists and "whereis lpr" reply in "/usr/bin"
If I try
QProcess::execute("whereis lpr");
there's no reply.No problem. I try this command :
ls -l /usr/bin
With gnome-terminale, I found a lot of files and lpr, lp and somes others files depending of snap installations.
With QProcess and system, nothing from snap is present.
Do you know why and what is the good way to execute a command installed by snap with QProcess or system, please ?
wrote on 24 Aug 2023, 00:42 last edited by@Stormbringer1900 said in How to execute command installed with snap:
QProcess::execute("lpr ...");
QProcess::execute() takes a program name and a separate list of arguments. Since there is no executable named
lpr ...
this will fail.The non-Qt
system()
call passes the entire command string to a shell. If the shell cannot find the program after parsing the command then it either does not exists at all, or is not in the PATH of the launching process.If I try QProcess::execute("whereis lpr"); there's no reply.
Same as above.
With QProcess and system, nothing from snap is present.
Then the relevant directory is not in the PATH inherited by your process. On my Ubuntu machine the
/snap/bin
directory is in the system-wide path.However, I do not see a connection between
lpr
and snap. On a generic Ubuntu machinelpr
is a compatibility tool installed as a native application by CUPS:$ dpkg-query -S /usr/bin/lpr cups-bsd: /usr/bin/lpr
-
@Stormbringer1900 said in How to execute command installed with snap:
QProcess::execute("lpr ...");
QProcess::execute() takes a program name and a separate list of arguments. Since there is no executable named
lpr ...
this will fail.The non-Qt
system()
call passes the entire command string to a shell. If the shell cannot find the program after parsing the command then it either does not exists at all, or is not in the PATH of the launching process.If I try QProcess::execute("whereis lpr"); there's no reply.
Same as above.
With QProcess and system, nothing from snap is present.
Then the relevant directory is not in the PATH inherited by your process. On my Ubuntu machine the
/snap/bin
directory is in the system-wide path.However, I do not see a connection between
lpr
and snap. On a generic Ubuntu machinelpr
is a compatibility tool installed as a native application by CUPS:$ dpkg-query -S /usr/bin/lpr cups-bsd: /usr/bin/lpr
wrote on 24 Aug 2023, 08:15 last edited by@ChrisW67 said in How to execute command installed with snap:
Then the relevant directory is not in the PATH inherited by your process. On my Ubuntu machine the /snap/bin directory is in the system-wide path.
Which is as I wrote above.
However, I do not see a connection between lpr and snap. On a generic Ubuntu machine lpr is a compatibility tool installed as a native application by CUPS:
I agree, this has nothing to do with snap. It should be in
/usr/bin
. That should be on $PATH already.@Stormbringer1900 said in How to execute command installed with snap:
If I try
QProcess::execute("whereis lpr");
there's no reply.whereis
itself is in/usr/bin/
. If by any chance, somehow,/usr/bin
is not onPATH
then thewhereis
itself will fail to execute. What is the return result fromQProcess::execute()
? Did it write anything to stdout/err?Probably the first thing to try is
echo $PATH # or possibly /bin/echo $PATH
Compare calling via
QProcess
from Qt app against what it is in external shell wherelpr
etc. work.
1/5