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 01:23 AM
How to execute script one by one in automated env madhusmita Shell Programming and Scripting 1 07-02-2008 06:16 AM
i want automated script arghya_owen Shell Programming and Scripting 3 06-16-2008 10:02 AM
Need help for automated shell script uneex Shell Programming and Scripting 4 05-01-2008 01:15 PM
help for automated script splax UNIX for Advanced & Expert Users 4 12-26-2006 05:36 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-09-2008
leimrod leimrod is offline
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.
  #2 (permalink)  
Old 07-09-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,437

Code:
.......
test ! -d `date "+%Y/%m/%d"` && mkdir -p `date "+%Y/%m/%d"`
cd `date "+%Y/%m/%d"`
.......

  #3 (permalink)  
Old 07-09-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,330
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 01:47 PM..
  #4 (permalink)  
Old 07-10-2008
leimrod leimrod is offline
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
  #5 (permalink)  
Old 07-09-2008
jyoung jyoung is offline
Registered User
  
 

Join Date: Nov 2001
Location: Flint, MI
Posts: 228
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

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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