On OpenWRT, I have a Lua script on_new_device.lua that runs fine if I execute lua on_new_device.lua; however, I'd like to run it simply by executing ./on_new_device.lua.
Executing ./on_new_device.lua returns this error...
root#router:~# ./on_new_device.lua
-ash: ./on_new_device.lua: not found
The file has execute permissions...
root#router:~# ls -la ./on_new_device.lua
-rwxrwxrwx 1 root root 1094 Jun 18 11:06 ./on_new_device.lua
The file starts with #!/usr/bin/lua...
root#router:~# head -1 ./on_new_device.lua
#!/usr/bin/lua
How can I execute this file directly?
Can you wrap it in a script?
Copy this into a test.ash file:
#!/bin/ash
/usr/bin/lua /[path]/on_new_device.lua
Then chmod 755 on test.ash, and then you can run:
./test.ash
Bah, the problem was that the lua script was created on a Windows machine and had \r\n line endings. Saving the file with \n line endings solved the issue.
Related
I am using ant to deploy a file and then change the permissions of the file, but I am getting a 127 result to the chmod which means that there is an issue with the path or a typo:
[chmod] Result: 127
I have checked if the path to chmod was in the $PATH I am using and both check:
/program/EU/17_B_30/home/> echo $PATH
/products/maven/bin:/program/installs/java6/bin:/products/maven/bin:/program/installs/java6/bin:/program/EU/17_B_30/home/Jre/bin:/program/EU/17_B_30/home/Scripts:/opt/CollabNet_Subversion/bin/:/program/php/bin/:/usr/ccs/bin/:/usr/sfw/bin/:/opt/sfw/bin/:/program/installs/java6/jre/bin:/usr/local/bin:/usr/sbin:/usr/bin
/program/EU/17_B_30/home/> which chmod
/usr/local/bin/chmod
The same script executes without error on Linux hosts.
This is the ant task call that I am using:
<chmod file="${filesystem.target}/Scripts/file.sh" perm="ug+x"/>
Any questions/suggestions are welcome.
Thanks
I've written a short csh script that reads a file, which contains paths to files to be copied, then copies those files to a directory:
1 #!/bin/csh
2 #
3 # This script copies source and executable files modified to solve issues
4 # brought up by Veracode.
5 #
6
7 set tempdir = '~/updatedfiles2'
8
9 foreach line ( "`cat modifiedFiles`" )
*************here is the cp line**************
10 `cp -a $line $tempdir`
**********************************************
11 end
Which previously worked fine. I've since decided that I want to preserve the paths to these files in the form of a directory tree under that same tempdir directory because colisions are occuring when files with different paths have the same names.
(i.e. /vobs/emv/integratedClient/jniWrapper/OEMIMAKEFILE and /vobs/mv_components/utilities/general/OEMIMAKEFILE)
So, I tried to use the --parents option, like so:
1 #!/bin/csh
2 #
3 # This script copies source and executable files modified to solve issues
4 # brought up by Veracode.
5 #
6
7 set tempdir = '~/updatedfiles2'
8
9 foreach line ( "`cat modifiedFiles`" )
*************here is the cp line**************
10 `cp -a --parents $line $tempdir`
**********************************************
11 end
When I test it, it starts trying to copy the entirety of my system, starting in the root directory, which is not the effect I want. I'm just trying to copy over specific files, maintaining their directory structure as they are copied.
I've found some explanations of --parents, but none describe anything like what I'm seeing happening. Is it because I'm using --parents wrong? Is it my input file? I'm not sure.
The content of modifiedFiles (which is the value of tempdir) looks like this:
...
4 /vobs/emv/C_API/APIPrivate.cpp
5 /vobs/mv_components/utilities/class/Array.c
6 /vobs/mv_components/utilities/class/String1.c
7 /vobs/mv_components/export_functions/code/write_nastran_ortho3_none.c
...
/vobs is a root directory, so this may be effecting something with --parents. Has anyone heard of unrestricted recursive copying, despite specific file paths and no -r argument? Am I misunderstanding --parents?
Wow, I feel dumb.
After looking through it again and again, I've come to find what I've done wrong.
The actual command above is in a csh script. When a command is enclosed in front ticks (``) in a csh script, that command is executed, and the out put of that command is used by the shell. I was therefore doing the cp, then executing the output in the shell. I'm not sure why it was recursively copying upward, but removing those front ticks fixed everything. There was a previous error that I ignored in my original "working" script, and when I added the --parents option, the already broken script broke even more.
Moral of the story, be careful of front ticks!
For anyone who is interested, before:
...
9 foreach line ( "`cat modifiedFiles`" )
*************here is the cp line**************
10 `cp -a --parents $line $tempdir`
**********************************************
11 end
...
And after:
...
9 foreach line ( "`cat modifiedFiles`" )
*************here is the cp line**************
10 cp -a --parents $line $tempdir
**********************************************
11 end
...
Also, two of the entries in the input file were commented out in C style
/* comment */
That was causing the recursive copying from the root directory. Haha....eh. Stupid me.
I have the following in ./bash_profile
export SRCROOT=/users/benjamin.beasley/work/svn/ccdev
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk_dev/Contents/Home
export PATH=$PATH$:~/tools/tools-versions/gradle-2.2.1/bin
export PATH=$PATH$:~/tools/activator
In ~/tools/tools-versions/gradle-1.12/bin, I do
drwxr-xr-x# 4 xxx.xxx WORKDAYINTERNAL\Domain Users 136 Nov 12 11:47 .
drwxr-xr-x# 13 xxx.xxx WORKDAYINTERNAL\Domain Users 442 Apr 29 2014 ..
-rwxr-xr-x# 1 xxx.xxx WORKDAYINTERNAL\Domain Users 5071 Apr 29 2014 gradle
-rwxr-xr-x# 1 xxx.xxx WORKDAYINTERNAL\Domain Users 2395 Apr 29 2014 gradle.bat
echo $PATH$:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin$:/Users/xxx.xxx/tools/tools-versions/gradle-2.2.1/bin$:/Users/xxx.xxx/tools/activator90566
so I get the gradle executable which is executable. I can execute it from this directory. But if I start a new shell, and type "gradle" it says command not found. But I "echo $PATH$" and I see that the full canonical path to the ~/tools/tools-versions/gradle-2.2.1/bin folder is there.
However I can execute activator which is an executable in the ~/tools/activator directory. I have no clue why bash knows about activator and not gradle.
In summary:
gradle is executable by this user
gradle can be run from the command line.
gradle is in the $PATH$ environment variable
other programs such as activator, which are also in $Path$ are executable anywhere in terminal regardless of directory which is what I want to be true of gradle.
Unix environment variables are $PATH not $PATH$ (they aren't like Windows env vars).
This is causing your problem.
This path is busted: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin$:/Users/xxx.xxx/tools/tools-versions/gradle-2.2.1/bin$:/Users/xxx.xxx/tools/activator90566
Notice the 90566 at the end? That's from $$ having been expanded to the current process id when you set the variable.
None of these are paths that actually exist or work:
/opt/X11/bin$
/Users/xxx.xxx/tools/tools-versions/gradle-2.2.1/bin$
/Users/xxx.xxx/tools/activator90566
I would like to make my python script available to wherever I am. my python script is in /usr/share/pyshared/compteur so I have added the command to my .profile file export PATH=$PATH:/usr/share/pyshared/compteur
I rebooted my raspberry but if I try python compteur.py, it says it doesn't find the file.
How can I make this work?
ls -l folder gives
-rwxr--r-- 1 pi users 1273 Nov 30 15:26 camera.py
-rwxr--r-- 1 pi users 842 Nov 30 15:26 upload.py
head gives
head /usr/share/pyshared/compteur/camera.py
#!/usr/bin/env python
# Camera version 0.1
import RPi.GPIO as GPIO
from subprocess import call
import time
import ConfigParser
def main():
You can solve the problem by adding the command to your .bashrc (or .zshrc) file.
source $HOME/.profile
And restart your terminal. And all path setting in ~/.profile can work normally.
I want to use the Neo4j shell. With the V1.9 release, it was in the bin folder of the installation, but since I upgraded to v2.0.0-M06, I can no longer find it. The bin folder only contains the following files ...
Directory of C:\Program Files\Neo4j Community\bin
16/10/2013 15:38 <DIR> .
16/10/2013 15:38 <DIR> ..
16/10/2013 15:38 37 neo4j-community-user-vmoptions.loc
14/10/2013 09:38 491,016 neo4j-community.exe
16/10/2013 15:38 242 neo4j-community.vmoptions
14/10/2013 09:37 39,564,808 neo4j-desktop-2.0.0-M06.jar
4 File(s) 40,056,103 bytes
2 Dir(s) 16,272,773,120 bytes free
I know I can use the shell in the web UI, but I want to pipe input and output, and I can't figure how to do that except with the stand-alone shell. Any ideas?
I have found the answer - in another question - How to install Neo4j 2.0+ as a windows service .
By downloading the zip file rather than the windows installer, I get all the .bat files, including Neo4jshell.bat. Problem solved!
Try this:
cd C:\Program Files\Neo4j Community
jre\bin\java -cp bin\neo4j-desktop-1.9.4.jar org.neo4j.shell.StartClient [--file /your/file/of/stuff.cyp]