02-06-2009
Script to SCP a file to multiple servers
Hi All,
I am a total noob to the Unix world, and i hope to learn a lot from this wonderful community. Here's my first post and question , i am trying to SCP a file to multiple servers (multiple destinations) through this little script :
#!/bin/ksh
# copy files
# File to be copied
FILE="/tmp/$1"
LOCATION="/tmp/"
check()
{
if [ -f $FILE ]
then
echo "File found,preparing to transfer"
else
echo "File not found "
exit 0
}
while read server; do
scp -p $FILE $server:$LOCATION
done < server.txt
The server.txt contains the list of destination servers, and $1 takes the 'filename' as a parameter, for whatever the reason, everytime i run the script i get bumped with an error :
./sctest[8]: 0403-057 Syntax error at line 24 : `}' is not expected.
I tried removing the braces, that didn't help either. Please advise.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need to login into multiple servers thru a script run couple commands and run find command as root. I only have ssh access to the servers as a user than I can "su" to root. If you have a similar script please post it. Also if you can suggest commands that I should consider please let me know.
... (1 Reply)
Discussion started by: avcert1998
1 Replies
2. Shell Programming and Scripting
Hi guys , i have 1 problem and no find what is the problem...:confused:, and .netrc is configured and correct permissions...
REMOTE="/home/user"
LISTADO=`cat /root/home/user/LISTADO.txt`
MACHINE=$(echo $i|awk 'FS="|" {print $1}')
for i in $LISTADO
do
ftp $MACHINE <<TER
passive
prompt... (2 Replies)
Discussion started by: Esquizo000
2 Replies
3. Shell Programming and Scripting
Dear Experts,
how to run multiple scp commands from single scripts.
In a directory oracle redo files accumulate. i would like to copy those redo logs to my standby server. For same i am using scp to copy the files. where i am monitoring that as it is sending the files sequentially most of... (1 Reply)
Discussion started by: nmadhuhb
1 Replies
4. Shell Programming and Scripting
FILE_LIST="{a.txt,b.txt,cal*}"
scp -r $..$REMOTE_PATH$FILE_LIST $LOCAL_PATH
This script passes only when all the three files are transfere, wat if only two file are transfered, but still I was to make the return code as pass.
is it possible. (2 Replies)
Discussion started by: sangea
2 Replies
5. UNIX for Dummies Questions & Answers
Experts,
Im trying to remote into a server, run a script that resides on that server and capture the information displayed & store in a local file.
I struggled with this yesterday & finally that script is working now.
Now, here is a scope creep and the script that I wrote for 1 remote... (2 Replies)
Discussion started by: OMLEELA
2 Replies
6. Shell Programming and Scripting
Hi Folks,
I was given a task to append three IP's at the end of a specific (and unique) line within a file on multiple servers.
I was not able to do that with the help of a script. All I could was:
for i in server1 server2 server3 server4
do
ssh $i
done
I know 'sed' could be used to... (5 Replies)
Discussion started by: momin
5 Replies
7. Shell Programming and Scripting
Hello All,
I am new to scripting and I am trying to write a script which can scp a file from one box to multiple boxes.
I am thinking to do like this.
1) create a file with list of all server names
2)write a script which will pick up each server line by line from server list and copy it to... (1 Reply)
Discussion started by: sintilash
1 Replies
8. Shell Programming and Scripting
Hi,
I am new to scripting and i am trying to use below script to copy code to multiple servers and multiple locations on each server. the script is not working or doesnt give any error. Any help is appreciated. basically i want a script to get the code from a location (dir below) and read the... (2 Replies)
Discussion started by: Ron0612
2 Replies
9. Shell Programming and Scripting
I need to run a script on a bunch of remote servers. how can this be done without ssh into each individual server and run it
its under /sbin/script.sh on each server (1 Reply)
Discussion started by: tdubb123
1 Replies
10. Shell Programming and Scripting
Hi
I did the following script to ping multiple servers, but I keep on receiveing duplicate emails for one server that is down:
#!/bin/bash
date
cat /var/tmp/servers.list | while read output
do
ping -c 1 "$output" > /dev/null
if ; then
echo "node $output is up"
else
... (10 Replies)
Discussion started by: fretagi
10 Replies
UDHCPC(8) GNU/Linux Administrator's Manual UDHCPC(8)
NAME
udhcpc - very small DHCP client
SYNOPSIS
udhcpc [OPTION]...
DESCRIPTION
The udhcp client negotiates a lease with the DHCP server and executes a script when it is obtained or lost.
OPTIONS
-c CLIENTID, --clientid=CLIENTID
Send the client identifier CLIENTID.
-f, --foreground
Do not fork after obtaining a lease.
-H HOSTNAME, --hostname=HOSTNAME
Send the client hostname HOSTNAME.
-h HOSTNAME
Alias for -H HOSTNAME.
-i INTERFACE, --interface=INTERFACE
Configure INTERFACE.
-n, --now
Exit with failure if a lease cannot be obtained.
-p FILE, --pidfile=FILE
Write the process ID of the daemon to FILE.
-q, --quit
Exit after obtaining a lease.
-r ADDRESS, --request=ADDRESS
Request IP address ADDRESS.
-s FILE, --script=FILE
Use script FILE.
-v, --version
Display version.
USAGE
When an event occurs, udhcpc executes a script. There are four possible arguments to this script:
deconfig
deconfig is used when udhcpc starts, and when a lease is lost. The script should put the interface in an up, but deconfigured,
state.
bound bound is used when udhcpc moves from an unbound to a bound state. The script should configure the interface and set any other rele-
vant parameters (e.g., default gateway, dns server, etc.).
renew renew is used when udhcpc when a lease is renewed. The interface is already configured, so the IP address will not change. Other
parameters (e.g., default gateway, subnet mask, dns server) may.
nak nak is used when udhcpc receieves a NAK packet from the server. The enviromental variable $message will contain the reason for the
NAK message if the server included one. Processing this message is optional, as the script will also be called with deconfig if need
be.
Parameters are passed to the script via the following environment variables:
HOME The inherited HOME, or "/" if it is unset.
PATH The inherited PATH, or "/bin:/usr/bin:/sbin:/usr/sbin" if it is unset.
interface
The interface.
ip The client IP address.
siaddr The BOOTP next server option.
sname The BOOTP server name option.
boot_file
The BOOTP boot file option.
subnet The subnet mask.
timezone
The timezone offset from UTC in seconds.
router The list of routers.
timesvr
The list of time servers.
namesvr
The list of IEN 116 name servers.
dns The list of DNS servers.
logsvr The list of MIT-LCS UDP log servers.
cookiesvr
The list of RFC 865 cookie servers.
lprsvr The list of LPR servers.
hostname
The host name.
bootsize
The length in 512-octet blocks of the bootfile.
domain The domain name of the network.
swapsvr
The client's swap server.
rootpath
The path of the client's root dist.
ipttl The TTL.
mtu The MTU.
broadcast
The broadcast address.
ntpsrv The list of NTP servers.
wins The list of WINS servers.
lease The lease time in seconds.
dhcptype
The DHCP message type (safely ignored).
serverid
The server IP address.
message
Reason for a DHCPNAK.
tftp The TFTP server name.
bootfile
The bootfile name.
FILES
/usr/share/udhcpc/default.script
Script run when leases are obtained or lost.
NOTES
udhcpc responds to the following signals:
SIGUSR1
This signal causes udhcpc to renew the current lease or, if it does not have one, obtain a new lease.
SIGUSR2
This signal caused udhcpc to release the current lease.
GNU
/Linux 2001-09-26 UDHCPC(8)