PDA

View Full Version : Tip: using backticks



barrymavin
2017-04-14, 03:24
Did you know that Lianja provides tight integration with the command shell. The ` ... ` command sequence (backticks) can be used to run external shell commands that are piped together and to substitute the output into a Lianja character string.

Try this is the console:



? "Date is `date`"

HankFay
2017-04-14, 10:48
Hi Barry,

does something have to be set to make this work? In RC10, I am not seeing this work in the app inspector console, nor the main console, nor the command window. Win10 Pro.

Hank

PS: took me a good look to find the backtick -- I don't think I have ever used that for any real purpose before this. :) (It's under the tilde, top left, for those also searching...)

josipradnik
2017-04-14, 12:15
No luck here either.

Having different keyboards and language settings could be the reason.
What should be the ALT code for a backtick?

Josip

barrymavin
2017-04-14, 23:58
For those of you with non-US keyboards this post explains how to use the backtick.

https://superuser.com/questions/254076/how-do-i-type-the-tick-and-backtick-characters-on-windows

The use of the backtick comes from linux shell command line processing but it works on windows too.

Try this:



? "`dir`"

rcahoon
2017-04-17, 06:14
Barry,

I've tested this in RC10 and it doesn't appear to work. I'm using the same back tick character that I use regularly in my Angular 2 development without a problem.

1471

Cheers,

Rob C.

barrymavin
2017-04-17, 08:51
Rob,

This is not a new feature it has been in Lianja for a while and it it works perfectly well on my machine and others I have tested it on.

Try a different command such as dir rather than the example I gave which specifies date rather than date /T. date works in my machine as I have cygwin installed.

rcahoon
2017-04-17, 09:43
Barry,

I can't seem to make it work using any command.

1472

I'm using a fairly standard Logitech wireless keyboard with the back tick located immediately below the ESC key just left of the number 1 key. "Double ", 'Single ', `Back `

Not a major worry really. I just saw that others were having problems so thought I would add my two pence. :)

Cheers,

Rob C.

barrymavin
2017-04-17, 09:54
Rob,

It is all working for me. What operating system are you running on and is it 32 or 64 bit?

Josip is using a Croatian keyboard which has a different layout. I presume yours is a UK keyboard. The backtick character is displayed correctly. Probably a security issue or sonething related.

rcahoon
2017-04-17, 10:12
Barry,

I'm running Windows 7 Enterprise 64 bit with a standard UK keyboard. I don't see how security can be an issue unless Lianja requires some specific configuration in this regard. My comspec setting is "c:\Windows\system32\cmd.exe" and Run/Shell commands work just fine in my VFP and WebStorm IDEs.

I did some quick testing and found I have no problem with the commands to run external programs...

RUN "c:\Windows\System32\notepad.exe"

opens NotePad as expected. However...

RUN cmd

and

RUN "c:\Windows\system32\cmd.exe"

both cause Lianja to freeze and eventually crash.

Cheers,

Rob C.

phabio
2017-04-18, 02:16
Hi all,
I've a windows 10, 64 bit machine.
Just copy and past on my console (? "`dir`") and not work.

I've also try to enter the backtick character with "alt + 96", but I've no output.

ciao

Fabio

barrymavin
2017-04-20, 00:37
Rob,

As it turns out, the reason is that running operating system commands is OS specific.

As i mentioned in a previous reply, I have cygwin installed on windows.

On windows you need to do it like this:

? "`cmd /c date /t`"
? "`cmd /c dir`"

You are running cmd.exe which requires interactive input. You cannot run that using backpacks or the run command in Lianja.

I will look into the crash but it makes no sense anyway to try and run an interactive command shell from within Lianja.

If you have any issues like that with Lianja submit a ticket and the issue will be dealt with in due course.

barrymavin
2017-04-20, 00:47
Rob,

I see no crash whatsoever.

The interactive command window is probably behind the Lianja App Builder window.

1473

phabio
2017-04-20, 02:13
Yes Barry, this work fine!

thanks
Fabio

josipradnik
2017-04-20, 02:58
To summarize:

After select/copy/paste these examples in Console workspace on usual Windows:


? "`cmd /c date /t`" // works OK

? "Date is `date`" // does not work


Barry uses cygwin and both commands work for him.
If it is not easy to find backtick on the keyboard, the code for backtick is ALT+96

Josip

rcahoon
2017-04-20, 04:25
Barry,

I've tested the proper formatted commands using back ticks and they work as expected.

On further investigation I've found that it appears that when I "run cmd" from Lianja, it is cmd.exe that is hanging. Lianja is simply waiting for cmd.exe to finish. If I shut down cmd.exe from task manager, Lianja continues just fine.

So the crash is definitely an issue with my system and, as you say, since I have no reason to ever need to this in my code, it's not even an issue.

Once again, thanks for you efforts.

Cheers,

Rob C

barrymavin
2017-04-21, 05:27
I have simplified this behavior on Windows in Lianja 3.4RC14. You now no longer need to specify cmd /c you can just use the backticks but remember that the command itself must be a valid windows command that produces output.



? "The date is `date /t`"