The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
scp automated script gholdbhurg UNIX for Advanced & Expert Users 5 10-27-2008 12:23 AM
How to execute script one by one in automated env madhusmita Shell Programming and Scripting 1 07-02-2008 05:16 AM
i want automated script arghya_owen Shell Programming and Scripting 3 06-16-2008 09:02 AM
Need help for automated shell script uneex Shell Programming and Scripting 4 05-01-2008 12:15 PM
help for automated script splax UNIX for Advanced & Expert Users 4 12-26-2006 04:36 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-09-2008
Registered User
 

Join Date: Jul 2008
Posts: 2
Question Help needed with automated FTP script

Hi,

Ok, i'm trying to automate sending a DB backup from a linux box to a remote Windows PC via FTP. I can connect, send the file and create a folder, however I require that the backups be differentiated by date. Here is what my script looks like:

Code:
open *.*.*.*
user username password
lcd /location/of/DB/backup
mkdir %Y/%m/%d
cd %Y/%m/%d
put test.txt
bye
quit
This does not work, its just creates a folder named "%Y" with a folder inside it called "%m" with a "%d" folder inside that.

How would I go about creating folders with the date structure above on a the remote windows machine? All advice and help appreciated.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-09-2008
danmero danmero is offline Forum Advisor  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 901
Code:
.......
test ! -d `date "+%Y/%m/%d"` && mkdir -p `date "+%Y/%m/%d"`
cd `date "+%Y/%m/%d"`
.......
Reply With Quote
  #3 (permalink)  
Old 07-09-2008
Moderator
 

Join Date: Feb 2007
Posts: 3,549
Try something like this:

Code:
#!/bin/sh

Y=`date "+%Y"`
m=`date "+%m"`
d=`date "+%d"`

cd /location/of/DB/backup

ftp -i -n <<EOF
open "hostname"
user "user" "passwd"
mkdir "$Y"/"$m"/"$d"
cd "$Y"/"$m"/"$d"
put test.txt
quit
EOF
Regards

Last edited by Franklin52; 07-09-2008 at 12:47 PM..
Reply With Quote
  #4 (permalink)  
Old 07-09-2008
Registered User
 

Join Date: Nov 2001
Location: Flint, MI
Posts: 219
How about this.
Code:
file_date=$(date +%m%d%Y)
ftp -in 0.0.0.0 <<E-O-F
user username password
type ascii
mkdir $file_date
cd $file_date
put somefile
quit
E-O-F
Reply With Quote
  #5 (permalink)  
Old 07-10-2008
Registered User
 

Join Date: Jul 2008
Posts: 2
Quote:
Originally Posted by Franklin52 View Post
Try something like this:

Code:
#!/bin/sh

Y=`date "+%Y"`
m=`date "+%m"`
d=`date "+%d"`

cd /location/of/DB/backup

ftp -i -n <<EOF
open "hostname"
user "user" "passwd"
mkdir "$Y"/"$m"/"$d"
cd "$Y"/"$m"/"$d"
put test.txt
quit
EOF
Regards
Kudos! That works perfectly Much appreciated, you've made this Irishman very happy, I have one less job today, lol
Reply With Quote
Google The UNIX and Linux Forums
Reply

Bookmarks

Tags
None

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:




All times are GMT -4. The time now is 07:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66