Need help with Linux shell

I am trying to execute a linux command in a shell from a web app. This code works when I run it from the terminal[quote]bash -c “/home/test/RunNow 1 2 5”[/quote]
but when I run [quote]dim f as new FolderItem
dim args, s1 as string
dim sh as new shell
f = SpecialFolder.Home.Child(“test”)
args = " 1 2 5"
s1 = "-c " + chr(34) + f.Child(“RunNow”).AbsolutePath + args + chr(34)
MsgBox s1
sh.Execute s1[/quote]
The message box shows -c "/home/test/RunNow 1 2 5" which is exactly like the command I typed in the terminal. But the shell returns a long error message that begins[quote]bash: - :invalid option
Usage: bash… and a bunch of help in brackets that won’t print here[/quote]
Can someone point out to a Linux newbie what I am doing wrong. I must have tried thirty or more possible combinations.

The shell is going to be running bash by default. Why are you trying to send the “-c” command?

You can probably just send your command as is:

s1 = f.Child("RunNow").ShellPath + args

Note the use of ShellPath instead of AbsolutePath (which is deprecated).

Either include “bash” or omit “-c”. “-c” is an argument to the “bash” command that identifies the rest of the line as a command to execute. Note that in the terminal, you can run it either way:

bash - c /home/test/RunNow 1 2 5

  • or -

/home/test/RunNow 1 2 5

Use either form in shell.execute.

Edit: the above assumes that RunNow has its execute bit set. If not, use the first form of the command.

Thanks for the help. I figured learning Linux would be a piece of cake having started with CP/M then MS-DOS. Its orders of magnitude more complicated.