SOLVED command runs in shell, but not in script

Status
Not open for further replies.

4est

Cadet
Joined
Jan 13, 2017
Messages
2
I am trying to implement a script that backs up a folder 2times/week, and then deletes backups older than ~60days.
I've used this script on gentoo and ran flawlessly

However I can not seem to implement it to my FreeNAS
The script was using zip, but as zip is not included into FreeNAS I switched to tar.

My basic problem is that I can not seem to run tar in a script.
I have simplified the command:
tar -vcf /mnt/DATA.tar fld
running in shell works ok

running in script /bin/sh -x scipt.sh:
Code:
+ tar -vcf DATA.tar fld
: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors.

I tried using absolute paths, still not working.

Thanks
 
Last edited by a moderator:

4est

Cadet
Joined
Jan 13, 2017
Messages
2
I solved it: the problem was caused by ^M character (the script was written on windows)
 

melloa

Wizard
Joined
May 22, 2016
Messages
1,749
I solved it: the problem was caused by ^M character (the script was written on windows)

Yeap ... windows. I was about to say that I had no idea, even tested:
Code:
[root@backupnas] /mnt/raid# sh tardir.sh
tar: Removing leading '/' from member names
a mnt/raid/scripts
a mnt/raid/scripts/syncdatasets.sh
a mnt/raid/scripts/syncallcifs.sh
a mnt/raid/scripts/cover.txt
a mnt/raid/scripts/copyconfig.sh
a mnt/raid/scripts/ersync.sh
[root@backupnas] /mnt/raid# less tardir.sh
#!/bin/bash
#
tar -vcf compressedfiles.tar /mnt/raid/scripts
 
Status
Not open for further replies.
Top