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
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?
The below code is being used to trigger a shell command using Jenkins file.
sh """
val=\$(echo ${val} | sed 's/[^a-zA-Z0-9]//g')
echo ${val}
"""
The below error reflects as part of the code :
/home/me/#tmp/abcd/script.sh: command substitution: line 4: syntax error near unexpected token `('
Any solution to the same ? Thanks in advance!
This script
#!/bin/sh
once=true
while $once do
stop & PID=$!
sleep 10M
if [$!=0]; then
start
break
else
kill $PID
fi
done
Gives
./restart.sh: line 18: syntax error near unexpected token `done'
./restart.sh: line 18: `done'
I don't understand, it had run previously on another unix system. Am i missing something?
EDIT
stop and start are functions that simply run stop.sh and start.sh respectively.
You seem to be missing a semicolon on line 4. Modifying it to read
while ${once}; do
should fix it.
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