How to define a custom prompt in JShell from a script? - jshell

I am trying to create a custom JShell prompt and want to load it from a file directly.
But it is not showing the custom prompt when loading the set prompt from a file, but I am able to do it writing the same commands on JShell.
Ex:
I have a file 'jshell_prompt_file' contains these 3 lines to set the prompt:
/set mode genspice -quiet
/set prompt genspice "GetNetConnectivity > " "--------> "
/set feedback genspice
When I load the file while invoking JShell, it does not change the prompt.
1:31am [login1] ~/JSHELL 1023:-)jshell jshell_prompt_file
| Welcome to JShell -- Version 13.0.2
| For an introduction type: /help intro
jshell>
But when I copy-paste the same command to set feedback, then it changes it
2:53am [login1] ~/JSHELL 1034:-)jshell jshell_prompt_file
| Welcome to JShell -- Version 13.0.2
| For an introduction type: /help intro
jshell> /set feedback genspice
GetNetConnectivity >
Can someone help me to achieve this without the user have to type it on command prompt? I want the first prompt to be the custom prompt.

The feedback mode need to be set with a specific JShell command line option : --feedback.
In your file jshell_prompt_file keep only the first two lines:
/set mode genspice -quiet
/set prompt genspice "GetNetConnectivity > " "--------> "
and run JShell with:
jshell jshell_prompt_file --feedback genspice

Related

How do I run a .lua script in Notepad++?

I have a very basic .lua file saved in a folder, with just the code
print("Hello world")
I additionally have the standalone lua interpreter downloaded, but it is beyond me how to successfully run my code. I put all the files of the interpreter in the same folder but when I use F5 to run the program I see no text in the interpreter.
Run Notepad++.
On the menu select: Run -> Run.. (F5).
Insert: C:\path\to\lua.exe "$(FULL_CURRENT_PATH)"
Now you can run your scripts by pressing F5 on your keyboard.
Just do it with NppExec plugin:
SET interpreter = F:\lua\lua53.exe
SET exec = "$(interpreter)" "$(FULL_CURRENT_PATH)"
NPP_SAVE
$(exec)
if $(EXITCODE) != 0 goto exit
NPP_CONSOLE 0
NPP_RUN cmd /C "cmd /C $(exec) && pause"
:exit
KaMehHb's answer is correct, but one thing to add is either delete this line or change it to 1 if you want the console to stay up.
NPP_CONSOLE 0
to
NPP_CONSOLE 1

Glib AppInfo.create_from_commandline with NEEDS_TERMINAL only launches xterm or gnome-terminal

Why is this code only launching xterm or gnome terminal ?
I don't understand why it is not using user default terminal (x-terminal-emulator) on Debian, or even KDE default terminal.
AppInfo ai = AppInfo.create_from_commandline (
"ssh %s".printf (this.title),
"ssh", AppInfoCreateFlags.NEEDS_TERMINAL);
ai.launch (null, null);
Here is the list of what GDesktopAppInfo tries: gio/gdesktopappinfo.c#L2467-L2494
I believe the problem is that x-terminal-emulator is not standardized. If one were to push that as a freedesktop standard it would likely get implemented.

how to add "-env ERL_LIBS XXX" for "ct_run" command?

I have used "rebar generate" to create the package and move package to the test pc for running.
But when running the common test suite, I don't know how to "-env ERL_LIBS XXX" with "ct_run" command.
How to correct it?
ct_run -dir /home/peter/gate-0.0.1.20/lib/gate-0.0.1.20/ct -suite gate_test_data_SUITE.erl -erl_args -- -env ERL_LIBS gate-0.0.1.20/lib
This variable also works for the environment. Have you tried running the command as ERL_LIBS gate-0.0.1.20/lib ct_run -dir /home/peter/gate-0.0.1.20/lib/gate-0.0.1.20/ct -suite gate_test_data_SUITE.erl ?

erlang R16B01 and Windows CMD

I'm windows 7 user and try to learn erlang and here's the time when I get to the paragraph where I have to deal with creating and naming nodes. I used to start erlang emulator from shortcut and don't know how to start it from command prompt window to use -name or -sname commands, and when I try to use
net_kernel:start([node,shortnames]).
command I get
{error,
{{shutdown,
{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}},
{child,undefined,net_sup_dynamic,
{erl_distribution,start_link,[[node,shortnames]]},
permanent,1000,supervisor,
[erl_distribution]}}}
=INFO REPORT==== 23-Aug-2013::15:28:03 ===
Protocol: "inet_tcp": register/listen error: econnrefused
error. I thought it was because of windows firewall and turned it off, but nothing has changed. So can someone answer what's going on?? And if you don't mind teach me how can I start erlang from CMD and use -name and -sname commands.
1) make sure you have in the path, program files \ erlang \ bin \ erl
2) open the command prompt and type
3) erl -sname dilbert
-name = for fully qualified name [dilbert#mypc.maydomain.com]
-sname for short name [dilbert#mypc]
this will give you
% erl -sname dilbert
(dilbert#mypc)1> node().
dilbert#mypc
I am, most of the time, a windows user, and as it is not natural in this environment to use command windows, I used to write some command files to invoke werl (the usual VM interface in windows). But I stopped that, because it is less convenient and less flexible than the command window, and also because I very often need other command line tools like ping, ipconfig, or git...
I join an example of the code you can use:
launch_werl.bat:
echo off
echo Select a project:
echo 1: project 1
echo 2: project 2
echo 3: project 3
set /p proj=
goto label%proj%
:label1
d:
cd "\git\project1"
set prname=proj1
goto end
:label2
d:
cd "\documents and Settings\user\My Documents\path\to\some\code"
set prname=proj2
goto end
:label3
d:
cd "\git\proj3"
set prname=PLC
goto end
:end
start werl -sname %prname% -pa "./ebin"
echo on

How can I add a printer valid access code to a printer in a batch file?

I've got this so far:
Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prnport.vbs -a -r IP_192.168.1.78 -h 192.168.1.78
Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prndrvr.vbs -a -m "RICOH Aficio MP C5501 PCL 6" -h %CD% -i %CD%\OEMSETUP.INF
pause
Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prnmngr.vbs -a -p "Ricoh Aficio MP C5501" -m "RICOH Aficio MP C5501 PCL 6" -r IP_192.168.1.78
pause
The pauses are just for me to be sure everything is working right. The problem is, the printer has one of those valid access codes. I'm trying to automate the entire process, but I am having trouble adding the valid access code. Is there even a way to do that?
Figured it out!
So what you need to do is export printer settings from one that has already been set up.
rundll32 printui.dll,PrintUIEntry /Ss /n "Ricoh Aficio MP C5501" /a "settings.dat"
rundll32 printui.dll,PrintUIEntry /Sr /n "Ricoh Aficio MP C5501" /a "settings.dat"
So I ran the first line after setting up the printer. It gave me the .dat file. I can use that file on all the printers for this one office. I just appended the second line to the end of my code above, and voila! It works!

Resources