Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
google site



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

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Search this Thread
  #1  
Old 03-14-2010
Registered User
 

Join Date: Mar 2010
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Need some help with a small SFTP script

Hi there!

Could anyone help me out with a shell script that should..
- sftp myuser@myhost
- cd public_html/misc/
- mkdir `date --date='1 day ago' +%Y_%m_%d`
- cd `date --date='1 day ago' +%Y_%m_%d`
- put /home/localuser/files/*.log
- quit

Thanks for any help
Sponsored Links
  #2  
Old 03-14-2010
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 6,769
Thanks: 1
Thanked 66 Times in 61 Posts

Code:
fibbl=$(date --date='1 day ago' +%Y_%m_%d)
sftp myuser@myhost << EOF
 cd public_html/misc/
 mkdir $fibbl
 cd $fibbl
 put /home/localuser/files/*.log
 quit
EOF

Note: make sure the last EOF (or whatever you use to demarcate your here document)
is in column #1 of the script. Search the forums here for 'here document' if this is new to you.
  #3  
Old 03-15-2010
Registered User
 

Join Date: Mar 2010
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Thanks jim mcnamara!

Where do I place the password for the sftp session? It doesn't matter if the password is written directly in the script, but I've read about sftp -b passwordfile user@host, but how should the password file look like - nano passwordfile -> add my password -> save?

---------- Post updated at 10:16 PM ---------- Previous update was at 12:18 AM ----------

Anyone?

Sorry for bumping the thread, but I really need some help with this - thanks for any help! <3
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help in a small script gsabarinath AIX 7 03-03-2010 08:20 AM
small script help ali560045 Shell Programming and Scripting 9 01-18-2008 09:18 AM
small script everurs789 Shell Programming and Scripting 3 11-06-2007 04:08 PM
small script help rkl1 Shell Programming and Scripting 1 12-06-2005 10:26 PM
Need help in a small script super_duper_guy Shell Programming and Scripting 2 10-24-2005 10:06 AM



All times are GMT -4. The time now is 09:18 PM.