Starting an application on linux?


#1

7z is application

File f=File("/MEDIA/ALMACEN/APP/7z"); f.startAsProcess();

not working.


#2

Ok, well the method would do this:

…so does that work on this very odd system of yours? (…which has a root directory called “MEDIA” in capital letters?? Sounds extremely hacky to me…)


#3

MEDIA is a partition where Windows is installed.


#4

You didn’t answer my question from the previous post - does that command-line work or not?


#5

If 7z is a command program.

my code is:

String appPach="/bin/sh -c " + thisAppPach;
    SystemStats system;
    if(system.getOperatingSystemName()==T("Linux")){
     appPach<<"/7z/7z";
     appPach=appPach.replace(T(" "),T("\040"));
       }else{
    appPach<<"/7z/7z.exe";
    }
  File dirT;
    File f=File(appPach);
    String dit=ProyectoPach;
    dit<<"/make";
    dirT=File(dit);
    dirT.setAsCurrentWorkingDirectory();
   String coman="u -tzip \"" + mascota.zip + "\" *.xml *.png -r";
    f.startAsProcess(coman);

Note: my language is Spanish, spoke no English, utiliser google translator. sorry


#6

Sorry, I’ve no idea what’s going on there. You need to debug it properly.


#7

an example to run a program in linux, I can provide?


#8

I asked you a question twice, and you haven’t bothered to answer it. Why would I spend any time on this if you’re not even listening to what I say?


#9

my mistake when typing.

File f=File("/MEDIA/ALMACEN/APP/7z");
f.startAsProcess();

is

File f=File("/media/ALMACEN/app/7z");
f.startAsProcess();

but still not working


#10

error found, the problem is when the paths have spaces (" ").


#11

Hmm. Ok… Well, try this change in the linux file code:

bool juce_launchFile (const String& fileName, const String& parameters) { String cmdString (fileName.replace (T(" "), T("\\ "),false));

That should escape the spaces correctly.


#12

What about quoting the path instead ? (like in sh -c “/path/to/my application with ‘quote’ and space/app”)

BTW, if you plan to escape the space, you must escape “:”, “*” et al (these chars are allowed in linux’s path).
It’s easier to escape the doublequote and to doublequote the path.


#13

the best way is to escape with a ‘’ all potentially dangerous characters (they are numerous, ':;{}()& #' etc.. ) when you pass it to sh, otherwise you are opened to all sorts of side effects when the shell interprets the string for example if you launch an application named (xeyes) (and double-quoting does not protect you in that case).