LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-18-2009, 12:34 PM   #1
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,012

Rep: Reputation: 30
rm at bottom of script doesn't work


Any ideas why the rm instruction at the bottom of this script doesn't work when it works from the command line?

Code:
#!/bin/bash
mydate="$(date +%Y%m%d)"
#echo $mydate
/bin/tar cfz /usr/local/sbin/myscripts/backup-$mydate.tar.gz  /etc /var/log /var/www /usr/lib/squid/ncsa_auth /usr/local/sbin/myscripts

USER="username"
PASS="pwd"
FTPSERVER="myserverftp.com"
FILE1="backup-$mydate.tar.gz"

ftp -inv $FTPSERVER <<END_SCRIPT
lcd /usr/local/sbin/myscripts
quote USER $USER
quote PASS $PASS
put $FILE1
bye

/bin/rm -rf /usr/local/sbin/myscripts/backup*
 
Old 08-18-2009, 12:40 PM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
what are the error messages?
 
Old 08-18-2009, 12:40 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
It simply does not remove the tar.gz file or it gives some error message? Try to launch the script as
Code:
bash -x script.sh
this will display the actual command the shell will try to execute after the wildcard expansion. Useful for debugging.
 
Old 08-18-2009, 12:47 PM   #4
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,012

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by colucix View Post
It simply does not remove the tar.gz file or it gives some error message? Try to launch the script as
Code:
bash -x script.sh
this will display the actual command the shell will try to execute after the wildcard expansion. Useful for debugging.
no error at all. The shell output ends with this:
Code:
226 Transfer complete
21576713 bytes sent in 17 seconds (1.2e+03 Kbytes/s)
221 Goodbye.
[root@localhost myscripts]#
The file is created with permissions -rw-r--r-- 1 root root
 
Old 08-18-2009, 12:58 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Try to run without the -f option of rm. It should tell you if file is non-existent. Have you tried with bash -x?
 
Old 08-18-2009, 12:58 PM   #6
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Don't you need to have "EOF" (or possibly "END_SCRIPT" in your case) after "bye" to tell it to stop giving commands to ftp, or something?
 
Old 08-18-2009, 01:02 PM   #7
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,012

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Nylex View Post
Don't you need to have "EOF" (or possibly "END_SCRIPT" in your case) after "bye" to tell it to stop giving commands to ftp, or something?
Yes. oops.
Thanks
 
Old 08-18-2009, 01:03 PM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by Nylex View Post
Don't you need to have "EOF" (or possibly "END_SCRIPT" in your case) after "bye" to tell it to stop giving commands to ftp, or something?
Nylex, you hit the nail on the head!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
getting to the bottom of sound stabu Slackware - Installation 4 03-23-2009 05:47 PM
Ubuntu8.0.4- Lost top line and bottom line on desktop-No app guide- No work spc boxes pizzipie Linux - Newbie 1 12-24-2008 09:01 AM
How to get icons at the bottom misterminibus Linux - Newbie 1 11-16-2008 01:53 PM
Modify Perl script to work with txt - Permissions script joangopan Programming 4 09-14-2007 10:20 PM
restart bottom panel cch2cch Fedora 2 04-02-2006 06:02 PM


All times are GMT -5. The time now is 05:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration