Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Feeding input using a text file - reposted from Sun Solaris Forum

Status
Not open for further replies.

limester

Technical User
Dec 29, 2004
69
CA
Hi,

I orginally posted in Sun Solaris (apologies, now reposting in UNIX Scripting)

Would like to use /bin/sh
*nix version FreeBSD

I would like to parse the contents of a text file. This text file is built from a sql query.

/text_file.txt

Contents of text_file.txt would be:

012YYYYMMDDHHMMSS
012YYYYMMDDHHMMSS
012YYYYMMDDHHMMSS

each line will have a unique 'YYYYMMDDHHMMSS'

I will need to append .tar to each line and rcp to another server.

But, I will need to use the YYYYMMDD to specify target and source directory for the rcp command.

I also need to break up the YYYYMMDD into /YYYY/MM/DD/ as the file is stored this way in the filesystem (/YYYY/MM/DD/012YYYYMMDDHHMMSS.tar

Then use this to copy the file using rcp, then changing the permissions once it has copied to the other server.

For example:

rcp -p file.tar user@host:file.tar
rsh -l user host "chmod 755 file.tar"

Any help would be greatly appreciated!

Thanks!




 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV,

Thanks for the reply.

I am basically stuck at trying to write this script. I am not sure how I can parse the text file and I am not sure how to use the contents of the file to make the source and destination directory as well as filename to copy.

I know what I want to do with it, but not sure how to interpret this into commands in a shell script.

I have a few hundred entries in the text file so I am trying to automate this rather than running each rcp separately.

Any starting help would be greatly appreciated.

Thanks!
 
I am not sure how I can parse the text file
I'd use awk

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top