LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-30-2011, 02:04 PM   #1
senthil1186
LQ Newbie
 
Registered: Jul 2010
Posts: 4
Blog Entries: 1

Rep: Reputation: 0
Passing inputs to the script


Hi
I am trying to automate an operation of copying files of specific user to another server using a simple script.
The problem is I dont know how to pass a parameter which is a username to the remote command. Please look into the script below and help me out in sorting this out
Code:
#! /bin/bash
echo "Enter the username: "
read user
rsync --progress -avz -e ssh root@server1:/local/home/$user/local/home/;//copy files from remote server
ssh root@server1 'du -sh /hsphere/local/home/$1'; // checking the actual file size"this is where My question arouse"
du -sh /hsphere/local/home/$1 //checking the file size transferred.
Will this work?
~

Last edited by senthil1186; 08-30-2011 at 06:07 PM.
 
Old 08-30-2011, 02:13 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
At very least, sanitize your user input, a la:
Code:
user=$(echo $user | tr -d './')
(Just an example.)
 
Old 08-30-2011, 02:15 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
As for the more general question, use double quotes (not single quotes) around any variables you want to get substituted for values.
 
  


Reply



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
[SOLVED] Run script from another with multiple user inputs and expect ! zoonose Linux - Newbie 2 06-05-2011 08:57 PM
Create BASH script to process multiple inputs on read davisbase Linux - Newbie 5 05-26-2010 11:57 PM
shell script for a partial control over inputs to an external program njain Linux - Software 1 05-19-2010 07:57 PM
Is this possible to record inputs which will be provided during running script gangadhar_m Linux - Server 10 02-23-2010 03:10 AM
shell script inputs aloishis89 Programming 3 03-10-2008 02:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:10 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
Open Source Consulting | Domain Registration