[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Backup script



i have the same problem half a year ago: you need a blank in the first row of the script!

use:
#! /bin/bash

that should work...

bernd

Paul Howarth wrote:
Chris Norman wrote:
Hi,
I've got that, the only thing, when I run the script first hand, I get:

: Bad interpreter: No such file or directory

At the top, I have:
#!/bin/bash

I tried:
#!/bin/sh

But that got the same results. The permission bits are:

-rwxr--r-- root root

I'm running it as root.

No probs, I have fixed that, just re-wrote it, and it seemed to work.

You had probably created the script on a Windows box, which puts carriage return characters at the end of each line that confuse shells trying to interpret them.

 > I have
another problem now though:

Tar says it can't "stat" ls, says there's no such file or directory.

here's the script:

#!/bin/bash

cd /var/ftp/backup;

for file in ls
do {
tar cf /home/backup/$file.tar.tar $file/
} done


What is the problem?

$file has only one value in this loop, "ls".
What you want is to capture the output of "ls" and use that:

  for file in `ls`

or in bash (clearer)

  for file in $(ls)

or (better still, you don't need ls at all)

  for file in *

P.S. Please don't top-post on this mailing list.

Paul.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]