[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[OFF TOPIC] scripting help



I'm trying to write a script to retrive a file listed in a text file, $1. 
The text can contain multiple file locations, if the first location fails,
then it should try the next location, and so forth.  I've included a
sample file below. 

--- sample file ---
Version 1.0
url smb://164.67.106.190:VIVI/C/WINDOWS/HELP/CLOSEWIN.AVI
alternate url smb://128.54.221.165:ERIC/C/WINDOWS/HELP/CLOSEWIN.AVI
alternate url smb://169.229.88.61:REVNED/C/WINDOWS/HELP/CLOSEWIN.AVI
alternate url smb://128.125.244.62:ELISA586/C/WINDOWS/HELP/CLOSEWIN.AVI
alternate url smb://128.54.205.151:JASON508/C/WINDOWS/HELP/CLOSEWIN.AVI
alternate url smb://128.54.207.176:YANG/C/WINDOWS/HELP/CLOSEWIN.AVI
alternate url smb://128.54.228.31:VIKAS/DRIVE 1/WINDOWS/HELP/CLOSEWIN.AVI
alternate url smb://128.195.217.38:IDASSLER98/C/WINDOWS/HELP/CLOSEWIN.AVI
alternate url smb://128.253.175.163:SAVALLI/C/WINDOWS/HELP/CLOSEWIN.AVI
--- EOF --

Here is exactly what the script must do:  ($1 = text file/list)
1) read line 1 of $1 (version) and print it to stdout

loop until successful or all URLs fail {
a) read line n of $1
b) identify url type (ftp, http, smb, etc.)
c) execute appropiate sub routine for url type
}
2) print results message (successful or failure and reason)
3) terminate

smb sub routine {
a) identify ip address
b) identify host name
c) identify share
d) identify location of file
e) identify file name
f) execute subclient and retrive file
    smbclient "//$host/$share" -N -I "$ip" << !
    lcd "$local_download_path"
    cd "$dir"
    get "$file"
    exit
    !
g) print error message if any (file not found, unable to contact host,
    etc.)
h) return to main loop.
}

.. the other sub routines I can figure out from the smb routine.

My problem is how to read the lines and sort of the variables..  Right
now, I'm trying to write this script in a bash shell script--I can't
program yet.  I wouldn't mind using perl though. 

Many thanks in advance,
-Paul



--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: