The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-27-2006
budrito budrito is offline
Registered User
  
 

Join Date: Jul 2002
Posts: 22
Tricky script question

Hi,

I'm in the midst of writing a UNIX script that sftp's files to an external host and am stuck with a problem. The problem is that the files created on my server as a order number that correlates to a sequence of directories on the remote host which is where the file should be ftp'ed.

Example:
My server filename:
myserver> /home/ 572011 O4MP ORDS 188406 V01 DT 20060608154548.txt

The 4th field (188406 ) in my filename correlates to a directory on the remote server where the file should be store. So on the remote server we should be sftp'ing this file to path

Remote Server:
remoteserver> /Test Documents/TestOrders/180001-190000/188001-189000/188401-188500/188406

The remote server has about 30+ directories and sub-directory ranges created to facilitate this file transfer. Remote server directory listings as range level and sub directories follow:
100001-110000 110001-120000
180001-190000 270001-280000 300001-310000 320001-330000
330001-340000 350001-360000 370001-380000 380001-390000
390001-400000 400001-410000 410001-420000 420001-430000
430001-440000 440001-450000 450001-460000 460001-470000
470001-480000 480001-490000 490001-500000 500001-510000
510001-520000 520001-530000 530001-540000 540001-550000
550001-560000 560001-570000 570001-580000 580001-590000
590001-600000 600001-610000

So another example would be that if we received a filename:
/home/ 572011 O4MP ORDS 588406 V01 DT 20060608154548.txt (Note: 588406 is the directory to be stored on remote site as explained above)

How can I make the script smart enough for it to look at the forth field in my file name and sftp it on the remote server path:
remoteserver> /Test Documents/TestOrders/580001-590000/588001-589000/588401-588500/588406

This is for #!/bin/sh, #!/bin/csh or #!/bin/ksh and based on HP-UX 11i.

Your assistance would be greatly appreciated.

Thanks.