rename a file to include the ip address


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers rename a file to include the ip address
# 8  
Old 11-10-2006
Do you have to use ftp ?
If you can you use scp or rcp then you can use a for loop..

Something like this:
Code:
for host in `cat /tmp/listofhosts` ; do
     rcp $host:/path/to/filename /tmp
     echo "filename copied from $host"
     mv /tmp/filename /path/to/new/location/$host-filename
done

I think thats the correct syntax to use..
/tmp/listofhosts will be a file you create on your local system that lists each host you want to copy the file from.
Replace filename with the name of the file you want to copy.
Tornado
# 9  
Old 11-10-2006
here's the prototype using ftp assuming 'hostFile' contains list of hosts to transfer the file from - one host per line.
Code:
#!/bin/ksh

hostFile='myFileWithHosts.txt'
myUser='foo'
myPasswd='bar'

myFile2get='myFile'

while read host
do
ftp -n  <<EOF
   open ${host}
   user ${myUser} ${myPasswd}
   get ${myFile2get} ${myFile2get}_${host}
EOF
done < "${hostFile}"

# 10  
Old 11-12-2006
thanks guys, great help - edited the example and when it runs I get "no closing quote" - any ideas what that could be..

this is what I am running:

Code:
#!/bin/ksh

hostFile='GLOBAL_hostFile.txt'
myUser='****'
myPasswd='*********'

GLOBAL_BACKUP='full_export.dmp'

while read host
do
ftp -n  <<EOF
   open ${host}
   user ${myUser} ${myPasswd}
   cd /global/prd/cycle/export
   get ${GLOBAL_BACKUP} ${GLOBAL_BACKUP}_${host}
EOF
done < "${hostFile}"

apologies......

Last edited by MrMac; 11-13-2006 at 07:55 AM..
# 11  
Old 11-12-2006
pls do use vB codes - it would make it easier for the others/yourself to read what you're runing EXACTLY.

According to the error message you're 'missing quotes' (double or single) - I don't see any of them missing in the quote you've given. Try to match them one by one and may be repost the code appropriately.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Include file not running using igawk

Greetings. I'm on section 2.7 Including Other Files into Your Program in "The GNU Awk User’s Guide". I am on HP-UX POSIX running GNU Awk 3.1.0 I have written Test1.awk and Test2.awk as shown here: $cat test1.awk BEGIN { print "This is script test1.\n" } $cat test2.awk ... (2 Replies)
Discussion started by: RUCerius
2 Replies

2. Shell Programming and Scripting

Mailx command to include sender address

Hi, I m using mailx to send email. I am using sender=server name(display name) echo "body" | mailx -s "subject" -b "bcc address" "to address" -- -f "$sender". I should get email with sender as only display name. In stead i am getting displayname@server address. Please suggest Use code... (1 Reply)
Discussion started by: usrrenny
1 Replies

3. Shell Programming and Scripting

Copy down remote files and rename them to include the server name with full path

I need to pull down a good bit of files for another support team for an upgrade project. I have a server.list with all of the server names. I need to do two parts: FIRST: I have this example, but it does not list the server name in front of each line. #! /bin/bash for server in $(<... (10 Replies)
Discussion started by: asnatlas
10 Replies

4. Shell Programming and Scripting

Need to include two more columns in the file using awk

Hi, I have a input file with many records as below: 1J4RR4GG0BC508200 68646 1 N M i want my output file to be like with columns included dgismdh and timestamp : Example: 1J4RR4GG0BC508200 68646 1 N M dgismdh 2012-02-21 07:22:25.98591 How to do it.can we do using awk? Pls help. (6 Replies)
Discussion started by: sonam273
6 Replies

5. Shell Programming and Scripting

How do I include the file being compared into calculation?

nawk -F, 'NR==FNR{file=FILENAME;a++;next} a{if(FILENAME~file)next;b++;} END{ for(i in a){if(a && !b){print "NEW: "i}} for(i in b){if(b)print i"\t\t"b}}' OFS=, 123.csv *.csv I need to include 123.csv into the equation for the total output currently it compares whatever is on 123.csv against... (27 Replies)
Discussion started by: llcooljatt
27 Replies

6. Shell Programming and Scripting

include file name to extracted files

I've written the script below to merge only .txt files that exist in one directory into one huge .txt file and ignore other files with other extensions. now the result is one huge .txt file with all the contents of other .txt files how can i add a File Name as a comment before each file? ... (12 Replies)
Discussion started by: miss_dodi
12 Replies

7. UNIX for Dummies Questions & Answers

Need to include getting latest file and rename into some generic name

I have a sftp script which was earlier getting a file with the same name, but now, i need to get the same log file which has been moved to a different directory which has all the historical logs which have the time stamp suffixed ex: testfile.log.020111 testfile.log.020211 So now i have to get... (0 Replies)
Discussion started by: win4luv
0 Replies

8. Programming

Cannot find include file: <sqlca.h>

All, I am getting the following error License : Got the license for Sun WorkShop Compiler C SPARC continuing.. "rlnseg_test.c", line 300: cannot find include file: <sqlca.h> "rlnseg_test.c", line 417: undefined symbol: sqlca "rlnseg_test.c", line 447: undefined symbol: sqlca... (2 Replies)
Discussion started by: thana
2 Replies

9. Programming

Not able to compile Pro*c file due - give errors and points to /usr/include/.. file

I am trying to compile the pro*C file but gives errors. It says it encountered "std" while it was expecting ; , = ( $ $ORACLE_HOME/bin/proc tradewind/dataaccess/Blob.pcc Pro*C/C++: Release 10.2.0.3.0 - Production on Fri May 9 11:10:54 2008 Copyright (c) 1982, 2005, Oracle. All rights... (0 Replies)
Discussion started by: shafi2all
0 Replies

10. Shell Programming and Scripting

how to include header file in b-sh script

I'm new in this. In C/C++, you define variables in one header file & then simply include it in any files where those variables are referenced. I tried to include a header named DefineVars- which initializes all the globals- but when I add the line "DefineGlobals" at the begining of another... (2 Replies)
Discussion started by: bluemoon1
2 Replies
Login or Register to Ask a Question