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?
Related
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!
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.
I am configuring Cron to backup my sql automatically. However I think that Cron has some issues and it's not working well.
This is the command I am running:
mysqldump --opt -Q -uhereisthename -p'hereisthepasswordwithstrangecharactersthatmustbeescaped' databasename | gzip > /home2/username/backups/backupnamefolder/backupdbwebsitename.`date +"%Y-%m-%d"`.gz
When I run it via SSH it works fine and generates the backup.
However if I run it via Cron, I get the following error:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file
Anybody can suggest what's wrong?
Cron treats % as a special character (meaning "new line", hence the references to lines 0 and 1 in the error message). You need to escape it:
date "+\%Y-\%m-\%d"
By the way, the posix $( ) syntax is generally better than backticks - it allows nested commands.
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