I'm trying to use unison from bash on windows with cygwin. I don't know if this is a cygwin question, bash question or unison question. Since I always get reprimanded by the cygwin mailing list for assuming it is a cygwin problem, I'll assume it is a bash question.
The following commands work from the bash command prompt:
However, when I put them in a bash script and chmod +x backup.bash I get the following errors:
Quote:
chmod +x backup.bash
./backup.bash
./backup.bash: line 12: $'ls\r': command not found
./backup.bash: line 13: $'\r': command not found
./backup.bash: line 36: $'\r': command not found
Error: Ill-formed name of file in UNISON directory: /cygdrive/c/busines
Compilation exited abnormally with code 3 at Sat Feb 09 13:51:56
Incidentally, I'm editing using emacs and emacs is not showing any control characters. So I'm mystified where bash is complaining about '\r'!
Also, the line numbers don't align correctly because I deleted a lot of comments.
I just when back to the script file and noticed that someone has inserted ^M at the end of each line! Hmmm... This could explain some of those error messages. While this is still a bash question, it might be a windows problem. Is there a way to make bash tolerate the ^M?
Here is the entire file:
Here are all the error messages again after I ran it again after remove the ^M at the end of each line.
Quote:
bash-3.2$ set -xv
bash-3.2$ ./backup.bash
./backup.bash
+ ./backup.bash
: invalid option
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
./backup.bash: line 13: $'ls\r': command not found
./backup.bash: line 14: $'\r': command not found
./backup.bash: line 37: $'\r': command not found
Error: Ill-formed name of file in UNISON directory: /cygdrive/c/busines
bash-3.2$
The below command works in the terminal interactively but not as part of a bash script. I though maybe I needed to escape the "$dir" so it isn't interpreted literally, but that's not it. Thank you :).
interactively in terminal
dir=/path/to
new=$(ls "$dir"/*.csv -tr | tail -n 1) && echo... (6 Replies)
Hi,
maybe I'm asking a VERY dumb question, but would anybody out there tell me, why this f****** script won't work if executed as a cronjob, but works fine if executed from a shell prompt?
#! /bin/bash
set PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
date >>... (3 Replies)
Hi everyone
I have a problem with my script
If I try directly this command
/usr/bin/nice -n 19 mysqldump -u root --password="******" wiki_schneider -c | nice -n 19 gzip -9 > /point_de_montage/$(date '+%Y%m%d')-wiki-db.sql.gz
It works
But if I simply add this command in a script and... (8 Replies)
I ran this script yesterday (in the background)
/usr/bin/nohup myfilelocation/myscriptname.sh &
the script worked perfectly.
i ran it today (also in the background) and just sat there. So i killed it and ran it normally and it worked perfectly.
Anyone suggest why it just sat there and... (8 Replies)
Hi, I've got a Bash backup script I'm trying to run on a directory via a cron job nightly. If I ssh in and run the script manually it works flawlessly. If I set up the cron to run evertything is totally messed up I don't even know where to begin.
Basically the path structure is
... (6 Replies)
Hello,
i have cronjob:
crontab -l
* * * * * pkill -f domexpcheck;sh /root/dom/domexpcheck.sh
it runs:
/var/log/cron
Mar 25 12:11:01 vps crond: (root) CMD (pkill -f domexpcheck;sh /root/dom/domexpcheck.sh)
but somehow script dont run properly via cronjob. But when i execute cronjob... (7 Replies)
Hi All,
FTP ports opens with the given user name and password and allows to download file through COMMAND PROMPT. Code as below:
H:\>ftp ftpxxxxx
Connected to entvc2ft07-pub.xxxxx.com.
220 Microsoft FTP Service
User (entvc2ft07-pub.xxxxx.com:(none)): userxxxxx
331 User name okay, need... (1 Reply)
I'm making a script that will be a double clickable .command file and I need it to prompt for the users admin password.
So far I have:
if ]; then
sudo -p "Please enter your admin password: " date 2>/dev/null 1>&2
if ; then
echo "You entered an invalid password... (2 Replies)
Hello,
So my knowledge of bash scripting is not that great and I have been trying to solve this problem on my own for awhile to no avail.
Here's the error I get when running it with an OS that uses bash 3.2.x:
testagain.sh: line 10: *-1: syntax error: operand expected (error token is... (2 Replies)
I am having trouble running a .sh file. The code 'x=${file_name:0:$z-11}' is giving me a bad substitution error. However when I run in BASH it works. Thing is when this goes to production the .sh will not be running in BASH. Is there a way to substring a string not in BASH or a way to invoke... (2 Replies)