• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Bash script problem

reicherb

Platinum Member
Here is the script I'm using

#!/bin/bash
#backup
rsync -av --progress 192.168.3.20::BACKUP/word /media/nss/BACKUP/current

# backup rotation script
BACKUPBASE=/media/nss/BACKUP
BACKUPDIR=current
DATEDIR=`date +%Y-%m-%d-%a_%H-%M`

mkdir $BACKUPBASE/$DATEDIR
cp -Rl $BACKUPBASE/$BACKUPDIR/* $BACKUPBASE/$DATEDIR/

the rsync part is working fine but when it tried to make a new directory I'm getting the following

sent 1092 bytes received 5733 bytes 546.00 bytes/sec
total size is 5729690 speedup is 839.52
: command not found
: command not found
mkdir: cannot create directory `/media/nss/BACKUP\r/2005-12-07-Wed_10-46\r\r'😱 such file or directory
cp: cannot stat `/media/nss/BACKUP\r/current\r/*': No such file or directory
: command not found
server2:/usr/bin #

Where is the \r coming from?

Thanks.
 
um, that's a bash script, not a perl script 😉

the \r is something from you date line, I would guess
 
Will do.

I'm running SLES (SUSE 9with Novell Open Enterprise server) and am using NSS volumes. I'm not sure that should make a difference though.
 
Ok, I'm totally lost.

if I run perl SISD.sh the command runs but I get the errors listed about (both w/ and w/o -x)

If I run exec SISD.sh (w/ -x) the terminal windows closes with a status of 2.

If I run exec SISD.sh (w/o -x) I get:
server2:/usr/bin # exec SISD.sh
: bad interpreter: No such file or directory
-bash: /usr/bin/SISD.sh: Success

I'm totally lost here. Shouldn't a shell script be pretty straight forward? I've verified that /bin/bash does exist. What else might it be?
 
Run the script (with the -x). Give us all of the output.

EDIT: Also, how is it being run? Through cron, manually, ??
 
I gave all of the output 2 posts up. I'm not getting the same result I was getting the other day.

I'm running it manually at the console.
 
Originally posted by: reicherb
I gave all of the output 2 posts up. I'm not getting the same result I was getting the other day.

I'm running it manually at the console.

If you say so. The post is confusing.

Ok, I'm totally lost.

if I run perl SISD.sh the command runs but I get the errors listed about (both w/ and w/o -x)

It's not perl, why run it with the perl interpreter?

If I run exec SISD.sh (w/ -x) the terminal windows closes with a status of 2.

Why use exec? If the xterm is crashing when you run a command, something is seriously borked on the system. Run a memory test.

If I run exec SISD.sh (w/o -x) I get:
server2:/usr/bin # exec SISD.sh
: bad interpreter: No such file or directory
-bash: /usr/bin/SISD.sh: Success

Why not include some debugging commands in the script so we know what's going on (especially since the -x for bash isn't working :|)?

EDIT: Something like:
#!/bin/bash -x
#backup
echo "Beginning rsync now."
rsync -av --progress 192.168.3.20::BACKUP/word /media/nss/BACKUP/current
echo "rsync done."

# backup rotation script
BACKUPBASE=/media/nss/BACKUP
BACKUPDIR=current
DATEDIR=`date +%Y-%m-%d-%a_%H-%M`

echo "DATEDIR is ${DATEDIR}"

echo "Making the directory ${BACKUPBASE}/${DATEDIR}"
mkdir $BACKUPBASE/$DATEDIR
echo "Done."
echo "Copying the files to the backup directory."
cp -Rl $BACKUPBASE/$BACKUPDIR/* $BACKUPBASE/$DATEDIR/
 
First, where did you create script? If it was on Windows, the carriage returns are probably wrong and you need to fix them with dos2unix or vim.
Second, if you use 'mkdir -p' it'll create the full directory path no matter what, otherwise it'll fail if any parts of the path except thte last are missing.
 
Thanks guys. The problem was carriage returns made in Windows. I did add the echo commands which are helpful though.

Thanks!
 
Back
Top