trouble converting Terminal command to Xojo shell

The following works perfectly in Mac OS X Terminal:
unzip -jq ~/Desktop/filename.zip pathToFile -d ~/Desktop/testFolder

How can I accomplish this simple task using Xojo? Documentation on using shell commands in Xojo seems scarce. Frustration has been building up. Many thanks in advance!

Try…

[code]Dim ZipShell as new Shell

ZipShell.Execute “unzip -jq ~/Desktop/filename.zip pathToFile -d ~/Desktop/testFolder”

//can use ZipShell.Result to see if any errors were output

ZipShell.Close[/code]

:slight_smile:

May have to replace the paths using FolderItems, and the FolderItemName.ShellPath in the command line arguments.

What is your code? Do you get an error? It seems like what Matthew posted ought to work, but remember Shell is not the Terminal. From the doc page:

[quote=208515:@Bio Logic]The following works perfectly in Mac OS X Terminal:
unzip -jq ~/Desktop/filename.zip pathToFile -d ~/Desktop/testFolder

How can I accomplish this simple task using Xojo? Documentation on using shell commands in Xojo seems scarce. Frustration has been building up. Many thanks in advance![/quote]
Use the full path to UNZIP

/usr/bin/unzip

a Shell is not Terminal and it does not have all the env vars and paths for locating apps set up like terminal

A convenient way of testing the command before using it in shell, is to use the
/Example Projects/Advanced/Shell/Interactive Shell.xojo_binary_project

It acts like a terminal, but it has the same limitations as the shell it uses.

Why do you sometimes write

Shell.Close

and sometimes not ?

Matthew Combatti write it in his code above, but it’s not written in the Xojo’s examples.

Thank you for your suggestions. The command works when typed in the interactive shell project. A solution seems right at hand now!

[quote=208554:@Thomas ROBISSON]Why do you sometimes write

Shell.Close

and sometimes not ?

Matthew Combatti write it in his code above, but it’s not written in the Xojo’s examples.[/quote]

If shell is DIMed in the method, it goes out of scope when the method ends. So in principle, Close is not necessary. But it does not hurt to do it.

Thank you Michel. Then I will add “Shell.Close” each time I do a Shell command (when finish). As it’s the normal way to do. It’s the same as “For MyVar = 1 to 10”, a simple “Next” is enough but I always write “Next MyVar”.

Sure. Next I, End If, Shell.Close can be considered figures of style, yet they participate in writing good code.

I tend to add to end if what the logical test was in comment, especially when there are nested if end if. Like

end if // A > B

These sorts of thing appear superfluous sometimes on the moment, but when it is necessary to read the code years later, they become very useful.