RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

Example of simple bash script ftp client

Very often I need to upload some files to my web server from a command line. entering a user name and password, changing directory can be little tedious work. Here is a small bash script which make this work easier. This script first defines a variables such as hostname of the ftp server, username and password and then it creates ftp session and uploads file into your selected directory:

#!/bin/bash

ftp_site=myhostname
username=myusername
passwd=mypass

PS3='Select a destination directory: ' 

# bash select
select path in "." "public_html/" "public_html/myblog/" "backup/images/" 
do
ftp -in <<EOF
open $ftp_site
user $username $passwd
cd $path
put $1
close 
bye
EOF
echo $1 uploaded to $path ! 

# Break, otherwise endless loop
  break  
done

EXECUTE:

$ chmod +x ftp_bash_script.sh
$ ./ftp_bash_script.sh file1

OUTPUT:

1) .                    3) public_html/myblog/
2) public_html/         4) backup/images/
Select a destination directory: 2
file1 uploaded to public_html/ !

Share this linux post:

Submit Example of simple bash script ftp client in Delicious Submit Example of simple bash script ftp client in Digg Submit Example of simple bash script ftp client in FaceBook Submit Example of simple bash script ftp client in Google Bookmarks Submit Example of simple bash script ftp client in Stumbleupon Submit Example of simple bash script ftp client in Technorati Submit Example of simple bash script ftp client in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download