I know how to load a single script when starting q session:
q myscript1.q -p 9001
what if I have two scripts both of which I want to load simultaneously at startup:
q myscript1.q myscript2.q -p 9001 doesn't work. Any suggestion?
Make use of QINIT, detailed here https://code.kx.com/q/basics/environment/.
It will load a script for you, and in that you can do as you please
// add the load of your file to a startup script
cat start.q
\l a.q
\l b.q
// export QINIT to be your startup script
export QINIT=start.q
// start q, it will load start.q, which will in turn load you startup scripts (a.q and b.q)
q
load one of the scripts at the start of the other.
eg. in the first line of myscript.q
\l myscript2.q
then when you run
q myscript.q -p 9001
both scripts will be loaded in your q session
Related
If I execute
sudo setcap cap_net_raw+ep /path/prog
and prog is a program which open a raw socket, can be prog still considered to run in user-space? How can I check it?
I want to run this command
telnet -a servername port
-CASServer V2.00 connection from 0.0.0.0 [] Diag mode only
status
Clients: Static 0/50 Dynamic 19/50
Application1: 1 0xcb4388 hSock(0x2d4)
Application2: 0 0
OK
I am basically only interested in "Dynamic 19/50". If possible, I'd like to get this information from PowerShell
The PowerShell script at http://community.spiceworks.com/scripts/show/1887-get-telnet-telnet-to-a-device-and-issue-commands might work for what your're trying to accomplish. It creates a PowerShell function called 'Get-Telnet'; it can establish a telnet connection and send a series of commands.
Your usage would be something like:
Get-Telnet -RemoteHost [servername] -Port [port] -OutputhPath results.txt
After which you could parse the data you need (e.g., the 'Clients' line) from 'results.txt'.
In order to run a cmd line application in PowerShell, specifically the telnet command, you first need to install telnet.
Use this command, with admin privs:
pkgmgr /iu:"TelnetClient"
After installing you can run your telnet -a servername port command in PowerShell:
Running a command line application (telnet) in PowerShell
I am not positive on what exact command line application you are trying to run. However here is an example of running a command line application in powershell.
&'C:\Program Files\gs\gs9.14\bin\gswin64c.exe' -sDEVICE=tiffg4 -dBATCH -dNOPAUSE -q -r600 "-sOutputFile=$OutputFullDirectory" "$InputPath"
This would be ghostscript however the key is using the & symbol to call the command line and then enter in the path to the exe file you want to run then you can pump in the parameters. Hope this helps lead you in the right direction
I'm having trouble to start a service as a specific user (under Ubuntu 14.4) and I'm unsure what the problem is. I use the following command to autostart a jar-file on startup:
nohup ${JAVA_EXEC} -jar ${MICROSERVICE_HOME}/bin/${MICROSERVICE_JAR} server ${MICROSERVICE_CONF} 2>> /dev/null &
That works perfectly, therefore there is no problem with the variables and so on. Well, this script get's executed by the actual user, which is in this case, the root. Since I don't want to take any risks, I do want to execute it as a specific (already existing) user. Normally my approach would be to change the to command to:
nohup su some_user -c "${JAVA_EXEC} -jar ${MICROSERVICE_HOME}/bin/${MICROSERVICE_JAR} server ${MICROSERVICE_CONF}"
But this doesn't work. I don't get any error messages (of course I left out the redirection of stderr for test purposes) and the nohup.out is empty.
I already have tried different versions, e.g. replacing the double quotes with single quotes and masking the "$" inside the command. According to this thread it should work with the syntax.
None of the solutions in that thread do work. E.g.
su some_user -c "nohup ${JAVA_EXEC} -jar ${MICROSERVICE_HOME}/bin/${MICROSERVICE_JAR} server ${MICROSERVICE_CONF}" -> doesn't work
nohup runuser some_user c "nohup ${JAVA_EXEC} -jar ${MICROSERVICE_HOME}/bin/${MICROSERVICE_JAR} server ${MICROSERVICE_CONF}"-> doesn't work (the runuser commands doesn't exist).
What do I miss?
Any help is very appreciated!
I have this problem:
I need to control the perl-debugger from an external script.
By research I found out about various solutions, but I don't understand them.
I failed to properly set up the RemotePort option (editing ".perldb"), which was the first I tried, and found no useful information on providing a filehandle from which the debugger would get its input (by somehow setting #cmdfhs)
I found both options over here: http://search.cpan.org/~nwclark/perl-5.8.6/lib/perl5db.pl
It would be nice if you could tell me how to provide the filehandle from which the debugger gets its input, or if you know a link where this is explained?
Here's a simple example setting it up using RemotePort, which seemed easier to me:
The trick to using RemotePort is that you have to have someone listening on the remote end BEFORE you launch the script to be debugged.
As soon as you launch your script with -d Perl will attempt to connect to RemotePort. So you have to make sure the initial connection succeeds by having someone listening there beforehand.
Here I assume some Linux/Unix variant, which has the netcat utility installed. We use netcat to wait for incoming connections in this example, but you can use anything else you wish too which is able to create a service port and shuffle data between that and the current TTY:
In terminal 1:
# Use netcat to listen for incoming connections on port 9999
> nc -l -p 9999
In terminal 2:
# Start perl with -d and request a RemotePort connection
> PERLDB_OPTS=RemotePort=127.0.0.1:9999 perl -d my_script.pl
As soon as you do that in terminal 1 you will see something like this:
Loading DB routines from perl5db.pl version 1.39_10
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(my_script.pl:4):
DB<1>
There you go..debug away.
Devel::Trepan is a gdb-like debugger. Although it has remote control, you can also run it at the outset with the option --command which will "source" (in the gdb-sense) or run a series of debugger commands.
To go into remote control, either start the debugger using the --server option or inside the debugger use the "server" command once inside the debugger.
See Options for a list of options you can give at the outset.
I'm using raspbian on a raspberry pi and I need to start a program on startup. What is the easiest way to do this? A bash script?
normally I run the following code in terminal:
../simple/./simple_run 12345
the executable has an input for 12345
Can someone step me through on how to do this?
Could you call your script at /etc/rc.local
If this file doesn't exist, create this:
#!/bin/sh -e
#
/.../myScript.sh
replace /.../myScript.sh by your script call... use full path.
Only one question... your script will be executed with "root" user... take care!