If I run the code in my own terminal using
sh projectbingo.sh
it shows as:
Hello World
hi
When I run the following code :
gnome-terminal --window-with-profile=tushar -x ./projectbingo.sh
A new terminal pops out but shows :
./projectbingo.sh: line 3: $'\E[H\E[2J': command not found
./projectbingo.sh: line 23: $'\E[H\E[2J': command not found
./projectbingo.sh: line 77: $'\E[H\E[2J': command not found
Got bus address: "unix:abstract=/tmp/dbus- 3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364"
Connected to accessibility bus at: "unix:abstract=/tmp/dbus- 3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364"
Registered DEC: true
./projectbingo.sh: line 79: $'\E[H\E[2J': command not found
Got bus address: "unix:abstract=/tmp/dbus-3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364"
Connected to accessibility bus at: "unix:abstract=/tmp/dbus-3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364"
Registered DEC: true
./projectbingo.sh: line 82: $'\E[H\E[2J': command not found
./projectbingo.sh: line 107: $'\E[H\E[2J': command not found
Got bus address: "unix:abstract=/tmp/dbus-3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364"
Connected to accessibility bus at: "unix:abstract=/tmp/dbus-3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364"
Registered DEC: true
./projectbingo.sh: line 110: $'\E[H\E[2J': command not found
./projectbingo.sh: line 116: $'\E[H\E[2J': command not found
Hello World\n\nhi
Please help !!!
This isn't a terminal issue. I suspect a shell issue.
Specifically, that $'...' notation is a bash-specific extension, but you are running the script simply by sh and not bash, so it won't apply.
Try changing the shebang line in the script to
#!/bin/bash
It was not a shell specific issue . I do not know why it happened ... but when I used
echo -e "Hello World\nHi"
It worked
But when i try it running sh projectbingo.sh it shows
-e Hello World
Hi
So My problem was solved but leading to the arrival of new problem
Related
I am trying to create a service using Automator.
Inside a Run AppleScript action I have a variable that is a string in which each line is a word separated by linefeed. Like this:
à
às
a
ante
ao
aos
após
aquela
When I try to echo this to terminal by doing:
do shell script "echo " & (finalText as string)
I get this error:
The action “Run AppleScript” encountered an error: “sh: line 1: a: command not found
sh: line 2: à: command not found
sh: line 3: ante: command not found
...
sh: -c: line 30: syntax error near unexpected token `do'
sh: -c: line 30: `do'”
Any ideas?
To get rid of the command not found type errors in this case, and just about anytime when passing a variable to a do shell script command, use:
do shell script "echo " & finalText's quoted form
You can also use:
do shell script "echo " & quoted form of finalText
Whichever you prefer as appropriate.
I have the following line in a bash boot script:
declare -fx $(bash -c "source ~/.local/bash.d/functions/10-git.bash &> /dev/null; compgen -A function")
I get no errors when firing up bash locally but when I ssh in from another machine, it causes a bunch of errors:
Last login: Fri Jan 31 09:25:00 2020
5.0.7(1)-release
/Users/me/.local/bash.d/exports/10-git.bash: cannot make pipe for command substitution: Too many open files
/Users/me/perl5/perlbrew/etc/bashrc: cannot make pipe for command substitution: Too many open files
/Users/me/perl5/perlbrew/etc/bashrc: cannot make pipe for command substitution: Too many open files
/Users/me/perl5/perlbrew/etc/bashrc: cannot make pipe for command substitution: Too many open files
/Users/me/perl5/perlbrew/etc/bashrc: line 19: cannot create temp file for here-document: Too many open files
/Users/me/.bashrc: line 8: read: read error: 0: Bad file descriptor
/Users/me/.bashrc: line 7: sort: command not found
/Users/me/.bashrc: line 7: find: command not found
/Users/me/.local/bash.d/exports/10-git.bash: line 10: declare: cannot use `-f' to make functions
Can't locate warnings/register.pm: Too many open files at /System/Library/Perl/5.18/vars.pm line 7.
BEGIN failed--compilation aborted at /System/Library/Perl/5.18/vars.pm line 7.
Compilation failed in require at /System/Library/Perl/5.18/darwin-thread-multi-2level/Config.pm line 11.
BEGIN failed--compilation aborted at /System/Library/Perl/5.18/darwin-thread-multi-2level/Config.pm line 11.
Compilation failed in require at /Users/me/perl5/perlbrew/bin/perlbrew line 3.
BEGIN failed--compilation aborted at /Users/me/perl5/perlbrew/bin/perlbrew line 3.
I'm guessing it's causing some kind of recursion but I'm unclear why this only happens when I ssh into the machine. Is there anything I can do prevent the errors?
I have a sh file running that calls a ps1 file in the end sh /test/ps1 . The PowerShell file sends an alert email saying that the script is complete. Not really sure why its throwing syntax error.
Following errors when bash is calling powershell test.ps1
./TEST.PS1: line 4: -t: command not found
./TEST.PS1: line 6: =: command not found
./TEST.PS1: line 7: To: command not found
./TEST.PS1: line 8: SmtpServer: command not found
./TEST.PS1: line 9: From: command not found
./TEST.PS1: line 10: Priority: command not found
./TEST.PS1: line 11: syntax error near unexpected token `}'
./TEST.PS1: line 11: `}'
Also I tried to run the following command on bash but hitting errors as well:
git send-email --f from#email.com --t to#email.com --smtp-server ##.###.###. ~/patches/*.patch
Having issues getting this shell script to run in windows task scheduler.
#!/bin/bash
# Script to ping the VPN server for testing
RESULT=$(ping 192.168.1.252 | grep "Lost" | awk {' print $10 '})
LOG=/home/admin/results.txt
if [ "$RESULT" -gt 0 ];then
echo "VPN 192.168.1.252 NOT pinging" >> $LOG
else
echo "VPN Online"
fi
When I run it in cygwin, it runs with no issue, but when I attempt to run it from command prompt, I get the following:
C:\cygwin64\bin>bash test.sh
test.sh: line 4: grep: command not found
test.sh: line 4: awk: command not found
test.sh: line 7: [: : integer expression expected
My question is, how do I get it to run with bash instead so that it actually knows the grep and awk commands?
In Windows Scheduler, I have Action: Start A Program
Details: C:\cygwin64\bin\bash.exe
Argument: test.sh
Start in: C:\cygwin64\bin
Am I missing something?
I figured it out.
In the Windows Task Scheduler, I had to pass:
Program/script: C:\cygwin64\bin\bash.exe
Add arguments: -c -l test.sh
Start in: C:\cygwin64\bin
In correction to what Jimmy found:
Add arguments: -c -l "c:/FileFolder/test.sh"
You don't need the Start in argument anymore.
For the longest time I was experiencing the same issue as the OP: command not found errors when trying to run a shell script from Task Scheduler or the Command Prompt, despite the fact that running the same script from a Cygwin terminal worked fine.
After some more research I eventually realised that the reason was because my usual Bash PATH ~/.bashprofile wasn't being loaded, and that I needed to use Windows' Environment Variables window to add C:\cygin64\bin to my PATH environment variable (system or user, it doesn't really matter). This directory contains common system executables like grep and awk, which is why Bash is unable to locate them until the path is added to Windows' PATH.
Hi new to unix and bash programming. I am trying to make a simple startup script to have my boxee start up XBMC that is stored on a Memory card. I can start the commands by entering them in telnet, but if i call the test.sh script it wont allow me to access the directory where XBMC is stored on.
#!/tmp/mnt/6337-3533/xbmc
BASEDIR=/tmp/mnt/6337-3533/xbmc $0
killall U99boxee; killall BoxeeLauncher; killall run_boxee.sh; killall Boxee; killall BoxeeHal
GCONV_PATH=$PWD/gconv AE_ENGINE=active PYTHONPATH=$PWD/python2.7:$PWD/python2.7/lib-dynload XBMC_HOME=$PWD ./xbmc.bin -p
gives:
# sh test.sh
: not foundne 2:
: not foundne 3:
test.sh: line 4: /tmp/mnt/6337-3533/xbmc: Permission denied
: not foundne 5:
: not foundne 6:
killall: U99boxee: no process killed
killall: BoxeeLauncher: no process killed
killall: run_boxee.sh: no process killed
killall: Boxee: no process killed
: no process killed
: not foundne 9:
: not foundne 10:
test.sh: line 11: ./xbmc.bin: not found
#
i used the command line from xbmc. and i assume the $PWD expects the script to be in /tmp/mnt/6337-3533/xbmc
if I enter "cd /tmp/mnt/6337-3533/xbmc" in telnet it wil bring me to the dir
but if i put that code in the script, it will give me access denied.
What am i doing wrong here. or how can i approach this so i wont have to change my work directory?
Line 2 will expand to
BASEDIR=/tmp/mnt/6337-3533/xbmc test.sh
This will try to run test.sh with the /tmp/mnt/6337-3533/xbmc interpreter specified on line 1, which will fail since that is a directory. Line 1 doesn't have to specify a valid interpreter if you're going to run the script by doing 'sh test.sh', but you'll probably be happier if you change line 1 to
#!/bin/sh
If you just want the invocation of xbmc.bin to see the value for BASEDIR in its environment, replace line 2 with
BASEDIR=/tmp/mnt/6337-3533/xbmc
export BASEDIR