Page 1 of 1
Why does shell with attrib does not work?
Posted: Sat Aug 22, 2015 2:48 pm
by mrcoollion
I get the following error on a simple shell command and I cannot find what I am doing wrong?
I only need to hide this folder.
Using Livecode 7.1.0-rc-1 Build 10040 (indy developer)
Working on Windows 10
Works fine as a commandLine in the Terminal window However I needer to use quotes before and after the folder path.
This worked fine in the commandline window:
D:\>attrib +h "D:\test folder\subfolder"
D:\>attrib -h "D:\test folder\subfolder"
D:\>
The error message: button "Hide folder": execution error at line 2 (Handler: can't find handler) near "shell", char 1
the script:
Code: Select all
on mouseUp
shell ("attrib +h D:\test folder\subfolder")
answer the result
end mouseUp
Also tried without succes:
Code: Select all
shell ("attrib +h " & quote & "D:\test folder\subfolder" & quote)
Anyone has a hint or tip?
Re: Why does shell with attrib does not work?
Posted: Sat Aug 22, 2015 4:18 pm
by ClipArtGuy
maybe this:
Code: Select all
shell ("attrib +h " & quote & "D:\test"&space&"folder\subfolder" & quote)
I have had trouble using shell command in windows when there are spaces in a path, although I mostly use Linux these days...
Re: Why does shell with attrib does not work?
Posted: Sat Aug 22, 2015 6:33 pm
by mrcoollion
Thanks ClipArtGuy for your reaction but no luck. Your suggestion does not work ;-(
It also does not work if I take the dpaces out of the folder name.
Regards,
Paul
Re: Why does shell with attrib does not work?
Posted: Sat Aug 22, 2015 6:37 pm
by zaxos
shell is a function, you have to put it or get it
Code: Select all
put shell("bla bla bla")
OR
get shell("bla bla bla")
Re: Why does shell with attrib does not work?
Posted: Sat Aug 22, 2015 6:55 pm
by mrcoollion
Thanks zaxos.
I am almost to embarrassed to say that you were correct.
Now with Put in front the shell command works.
Thanks again for the lesson.
to be complete for others this code shows what does and what does not work!
might be nice if this is also mentioned in the examples for the shell command at
http://docs.runrev.com/Function/shell
Code: Select all
on mouseUp
put 2 into thechoice
if thechoice is 1 then put "attrib +h D:\test folder\subfolder" into thecommand // does NOT work giving error: Parameter format not correct -
if thechoice is 2 then put "attrib +h " & quote & "D:\test folder\subfolder" & quote into thecommand // does work
if thechoice is 3 then put "attrib +h " & quote & "D:\test"&space&"folder\subfolder" & quote into thecommand // does work
put shell (thecommand) into tempvar
if tempvar is not empty then answer "error: " & tempvar
end mouseUp
Kind regards,
Paul
Re: Why does shell with attrib does not work?
Posted: Sat Aug 29, 2015 7:22 pm
by sturgis
Theres another thing I do on windows that makes things easier..
put shortfilepath("D:\test folder\subfolder") into tPath
at which point tPath has the old style 8.3 no spaces path to the file.
merge can be pretty helpful too.
If you have this string saved..
"attrib +h [[tPath]]" in a variable named tCommand
you can then
put shell(merge("tCommand"))
and it will replace [[tPath]] with the contents of tPath
So, if I did
put shortfilepath("C:\Program Files (x86)\RunRev\LiveCode Community 8.0 (dp 3)\LiveCode Community.exe") into tPath
the shell command shell(merge(tCommand)) would end up with
"attrib +h C:\PROGRA~2\RunRev\LIVECO~3.0(D\LIVECO~1.EXE" (note the shortfilepath version)
Re: Why does shell with attrib does not work?
Posted: Sat Aug 29, 2015 7:45 pm
by mrcoollion
sturgis wrote:Theres another thing I do on windows that makes things easier..
put shortfilepath("D:\test folder\subfolder") into tPath
at which point tPath has the old style 8.3 no spaces path to the file.
merge can be pretty helpful too.
If you have this string saved..
"attrib +h [[tPath]]" in a variable named tCommand
you can then
put shell(merge("tCommand"))
and it will replace [[tPath]] with the contents of tPath
So, if I did
put shortfilepath("C:\Program Files (x86)\RunRev\LiveCode Community 8.0 (dp 3)\LiveCode Community.exe") into tPath
the shell command shell(merge(tCommand)) would end up with
"attrib +h C:\PROGRA~2\RunRev\LIVECO~3.0(D\LIVECO~1.EXE" (note the shortfilepath version)
THX
