I have a problem with executing a command in Spring Shell. I'm using this code to blink my LED on a Raspberry PI but I'm getting a response error in the Tomcat's log.
JLineShellComponent shell;
Bootstrap bootstrap = new Bootstrap();
shell = bootstrap.getJLineShellComponent();
shell.executeCommand("gpio -g write 17 1");
shell.stop();
The log output is:
org.springframework.shell.core.SimpleParser commandNotFound
WARNING: Command 'sudo gpio -g write 17 1' not found (for assistance press TAB)
When I'm using the echo command the problem persists.
If you want to execute an OS Command via Spring Shell you have to prepend an exclamation mark.
shell.executeCommand("! gpio -g write 17 1");
A better solution is to use no Spring Shell at all
Runtime.getRuntime().exec("gpio -g write 17 1");
Related
I have multiple databases and have multiple sql scripts (250+). I am executing all the sql scripts on each of these databases. I am executing these scripts using SQLCMD.exe through PowerShell.
It is working fine when I am executing through 'Windows PowerShell ISE'. But following error is coming when I am executing this from TFS 2015 Release Definition:
The Win32 internal error "A device attached to the system is not functioning" 0x1F occurred while setting the console window title. Contact Microsoft Customer Support Services.
One Observation:
I have tried with reducing the SQL scripts or database with changing the order of database; but every time the procedure get fails after executing 3333 SQL scripts. So the problem might be of any Buffer size.
The SQLCMD execution line, I am using is as below:
& $SQLCMDFilePath -S $SQLServerName -d $DatabaseName -U $SQLServerUsername -P $SQLServerPassword -i $ScriptFullPath -b -l 60 -I -r -m 1 -o $fileName
Anyone has any idea about this?
I had the same problem and I found a solution that worked for me:
Just ran into this problem and solved it by selecting a true type font for Windows command prompt
https://social.technet.microsoft.com/Forums/lync/en-US/9c2b54a0-34dd-413e-ae32-ad2a00c3b12b/utf8-encoding-not-working?forum=winserverpowershell
tronbox unbox metacoin
Downloading...
Unpacking...
Setting up...
Error: Command failed: bash post-unpack.sh && rm post-unpack.sh && npm install
'bash' is not recognized as an internal or external command,
operable program or batch file.
at ChildProcess.exithandler (child_process.js:289:12)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:962:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
I have tried the command tronbox unbox metacoon in windows 10.
How to solve the above mentioned error? Same error is coming on trying command tronbox init. What can be the possible reasons for this bash error?
'bash' is not recognized as an internal or external command,
operable program or batch file'
This error comes when you try to run a shell script directly in window's command prompt.
If this error comes while unboxing metacoin DApp of tron, there is nothing to worry about. Metacoin DApp will be unboxed properly in your specified directory.
In case of IDEs Truffle or Tronbox, Shell scripts are basically used for running some javascript file. So, if you using truffle or tronbox on Windows, you can run javascript file direclty without running shell script for it first.
Solution for running javascript directly from window's command Prompt:-
Open shell script in an editor and try to locate the name of the javascript file in it. Now you can run this javascipt file directly from window's command prompt.
You need to use the following command in Window's command prompt (pre-requisite:- node.js is installed in your system:-
node filename.js
I have tried this for both the IDEs, truffle and tronbox. It works just fine.
I have a confusion over the exit code of the application and the bash return value. For an eclipse application, a command line interface ran using eclipse returns the exit code as 1 (which is expected upon error). but when I run same command line using shell file and checks the return value with "echo $?" it always returns value as 0.
Application launched in command line mode in Eclipse :
Shell script :
command ="toolCli.exe -application arguments"
$command
echo $?
Output I get here is always 0, what's exactly the difference here?
$ com="echoo hi"
$ $com
No command 'echoo' found, did you mean:
Command 'echo' from package 'coreutils' (main)
echoo: command not found
$ echo $?
127
As you can see the exit value does work, I believe your issue might be to do with the environment, as in the eclipse environment be different from your bash environment?
From the java path, it looks like you have a 64 bit windows env and that eclipse might be using the standard windows command line, so I'm interested in how you are expecting it to behave as a bash env?
So maybe run the command under a windows command line and see if it fails, compare the java setup in both environments.
When I run this on the command line it brings up the screen on my device to change the language.
$ adb shell am start -a android.settings.LOCALE_SETTINGS
works great.
I am trying the same functionality into a Python script that monkeyrunner calls.
How do you translate the above into something that will work with monkeyrunner / python?
e.g. I tried:
device = Monkeyrunner.waitForConnection()
package = 'android.settings'
activity = 'LOCALE_SETTINGS'
runComponent = package + '/' activity
device.startActivity(component=runComponent
This does nothing. No error message. But nothing.
Any suggestions?
android.settings.LOCALE_SETTINGS is not a component but an action. You can do either
device.startActivity(action='android.settings.LOCALE_SETTINGS')
or
device.startActivity(component='com.android.settings/com.android.settings.Settings$LocalePickerActivity')
I have a perl script that I need to run once at startup with an argument under my user account.
So when I boot the system up it needs to execute a command like this,
./path/to/script.pl start
Any ideas?
You could use a line in your crontab (crontab -e)
To run a command at startup:
edit /etc/crontab
Add the following line:
#reboot root perl ./path/to/script.pl start
^^^ Runs as root. Change "root" to "BlackCow" to run as BlackCow
Or, you could use upstart (add a .conf file to /etc/init/). Here's a copy and paste from my notes:
Use upstart to run a daemon at reboot/start
e.g. /etc/init/prestocab.conf:
#!upstart
description "node.js server"
author "BlackCow"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
script
export HOME="/root"
exec sudo -u root /usr/local/bin/node /home/prestocab/prestocab.com/www/socket.io/server.js 2>&1 >> /var/log/prestocab.log
end script
To use:
start prestocab
stop prestocab
restart prestocab
#
You might want to use some sort of process monitor to restart the daemon if it crashes
Depends on what init you are using, if your version of Ubuntu is using upstart
you have to configure the appropriate Upstart start scripts, if not
the rc scripts based on your runlevel. Check update-rc.d.
On Ubuntu, the simplest way is to add this line to your /etc/rc.local file (before the exit 0 line, substituting username with your own user name):
su -c "./path/to/script.pl start" username &