I have customized the primary prompt for bash shell but unfortunately it is not showing the current working directory as can be seen below.
[cifsamidala]w# pwd
/home/Vinod/SearchIdIssue
[cifsamidala]w#
Here is what I have customized my PS1:
HOST=`tput bold``hostname``tput sgr0`
PS1="[${HOST}]\w # "
Here is the Shell info for your reference.
[cifsamidala]w# echo $SHELL
/sbin/sh
[cifsamidala]w# echo $0
-sh
I also tried with 'pwd' as below but of no use.
PS1="[${HOST}]`pwd` # "
Kindly let me know if I am missing something here.
Thanks in avance.
Regards,
Vinod Yadav
Your shell is not the bash shell and this is probably the reason why it won't work. Ask your sysadmin to give you an unrestricted shell.
Related
I'm currently trying to create an installation tool. I have a a batch file calling some sqlcmd commands and I'd like to trigger it from Autoit. It works.
Now, I'd like to set a variable in Autoit (by getting it from a GUI) and pass it to the batch file when calling it. It should be something like this :
RunWait('path_of_file\mybat.bat' & %myVar%)
I read a lot from the Autoit community without finding the answer. I got things like :
RunWait('path_of_file\mybat.bat' & " " & $myVar) <- This solution didn't work for me
or
RunWait(#ComSpec & " /k "...) <- This one didn't suit what I'd like to do, as I'm
launching a batchfile and not a cmd command.
If anyone has an idea !
Thanks in advance :)
This should work:
Autoit works
Local $myVar = "ipconfig"
RunWait('mybat.bat ' & $myVar)
Autoit works too
ShellExecute("mybat.bat", $myVar)
mybat.bat
#echo off
echo %1
%1
ping 127.0.0.1 -n 6 > nul
I am unable to execute following command in unix as
e.g. ->
export ENVFILE=$PARENT_DIR/../env/.tpms.evr
while i try to execute . "${ENVFILE}" it shows me error as bash: 39910-: command not found
can anybody let me know about how to fix this.
You most probably have a line in .tpms.evr script which bash tries to execute as a command called "39910-"
Please share this .tpms.evr script or just that line containing "39910-"
When I did which groovy, I got the below output:
/usr/local/bin/groovy
So I went ahead and created a helloworld.groovy with the below content
#!/usr/local/bin/groovy
println "hello world"
After that I did chmod +x helloworld.groovy and attempted to run the file with ./hellworld.groovy and sadly, I got this error ./helloworld.groovy: line 2: print: command not found
I could get rid of the error by changing to
#!/usr/bin/env groovy
println "hello world"
Why would the first method cause the error?
You need to run the script like this:
groovy helloworld.groovy
#!groovy
println("hello world!")
$ chmod +x script.groovy
$ ./script.groovy
It will work on Linux kernel 2.6.28 (confirmed on 4.9.x). It won't work on FreeBSD and other Unix flavors.
Your /usr/local/bin/groovy is a shell script wrapping the Java runtime running Groovy.
See the Interpreter Scripts section of EXECVE(2) and EXECVE(2).
#!/bin/sh
sed '1,2d' "$0"|$(which groovy) /dev/stdin; exit;
println("hello");
i'm running Nginx on my Raspberry PI with PHP 5.4.14 (fpm-fcgi). It all works well. But in one script i make a shell call using shell_exec.
echo shell_exec("sudo python " . $file);
it works well if i use the console with
php test.php
but if i use the browser to call this file the php-file will be executed but i don't get any output by the shell_exec (not even an error message).
So i hope you could help me fix this problem.
The called python file makes use of the GPIO so sudo is required, right?
Here is my python code:
#!/usr/bin/env python
try:
import RPi.GPIO as GPIO
except RuntimeError:
print "Error Importing GPIO. Did your forgot the superuser privilieges?"
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(3, GPIO.OUT)
GPIO.output(3, not GPIO.input(3))
print "New LED state is: ", GPIO.input(3)
#GPIO.cleanup()
for future reference:
I found a - i my eyes - not really nice solution:
sudo echo "apache ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
Found here.
Mm, i have try with this two simple example:
/Scripts/test.py
#!/usr/bin/env python
print (str('hello world'))
/var/www/test.php
<?php
echo shell_exec('/Scripts/test.py');
?>
via a browser, show me "hello world"
Perhaps try this:
chmod a+x your_py_file.py
Hope that help..
I am using cygwin on windows 7 env and it is unable to locate java, error message i get is that
ERROR: /cygdrive/c/Program
Files/Java/jdk1.6.0_22 does not exist!
wired path is if I do echo $JAVA_HOME then it shows me
$ echo $JAVA_HOME
/cygdrive/c/Program Files/Java/jdk1.6.0_22
not sure what is happening here, any suggestions?
The problem is that the pathname contains spaces. You need to escape the spaces as described here:
http://www.cygwin.com/faq/faq.using.html#faq.using.filename-spaces
Adding this line to your .bashrc should do it:
export JAVA_HOME='/cygdrive/c/Program Files/Java/jdk1.6.0_22'
Edit: You could try running this script which I found in this blog post:
case "`uname`" in
CYGWIN*) cygwin=true ;;
esac
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
JAVA_HOME=`cygpath --windows "$JAVA_HOME"`
CLASSPATH=`cygpath --windows --path "$CLASSPATH"`
fi
Use the old school way:
export JAVA_HOME=/cygdrive/c/Progra~1/Java/jdk1.6.0_22
It worked for me.