[Gambas-user] Problem with Shell Gambas 3.10.0

Tobias Boege taboege at gmail.com
Thu Apr 19 20:13:54 CEST 2018


On Thu, 19 Apr 2018, Shannon Kuchler wrote:
> This is the Shell command I'm trying to run
> 
> 
> 
> p1 = Shell "steamcmd +login" & " " & UserName & " " & PassWD & " " & "+force_install_dir" & " " & CacheSaveLocation & "/" & dlDat[1] & " " & "+app_update 251570 -beta" & " " & dlDat[1] & " " & "+quit" Wait For Input As "Process"
> 
> 
> 
> in console it should look like this 
> 
> steamcmd +login username password +force_install_dir dirname/dirname +app_update 251570 -beta dirname  +quit
> 
> 
> 
> The problem is on most systems the shell command works just fine but on one system with a fresh install of  arch linux i get this error
> 
> /bin/sh: +force_install_dir: command not found
> 
> 
> 
> 
> it like it's skipping everything up to +force_install_dir in the command does anyone know why?
> 
> 

I have no explanation for this.

> 
> I can get it to work like this but  CacheDir is a directory with spaces same thing for dlDat1 it has spaces as well so that's not working either
> 
> p1 = Exec ["steamcmd", "+login", UserName, PassWD, "+force_install_dir", CacheDir, "+app_update", "251570", "-beta", dlDat1, "+quit"] For Input As "Process"
> 

And this is very weird. Exec should extra-work. In fact, you shouldn't be
using the Shell instruction because you don't need any shell features like
redirection. Exec is:

  o faster (you don't need to spawn and initialise a shell process,
    which has to parse your commandline),
  o less complicated (you don't have to quote anything), and
  o more secure (your above code is vulnerable to command injection
    via any of the variables you use).

(If you do need shell features, I would recommend using the Shell$() quoting
function instead of quoting with double quotes by yourself. Subst$() can be
used to make your commandline clearer, in addition.)

I very much doubt that the problem is with /bin/sh, and spaces in filenames
are perfectly fine. It's mostly the shell which gives you a headache with
spaces because space happens to be a control character in the shell language.
This isn't necessary with Exec at all. It passes its argument array directly
to the process.

How does the Exec line "not work either"? Are you sure that "+login" expects
UserName and PassWD in separate arguments? Some page I found [1] says that
you only specify the username. I suppose it will ask you interactively for
the password (which is sensible). But you'll know that better.

Regards,
Tobi

[1] https://developer.valvesoftware.com/wiki/SteamCMD#Linux.2FOS_X

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list