2 #----------------------------------------------------------------------
6 # Purpose: Convert a filesystem path to an xrootd url.
10 # file_to_url.sh [-h|--help]
11 # file_to_url.sh <file1> <file2> ...
12 # file_to_url.sh @<filelist>
13 # cat <filelist> | file_to_url.sh
17 # 1. Pnfs paths are converted to an xrootd url as
18 # /pnfs/... -> root://fndca1.fnal.gov:1094/pnfs/fnal.gov/usr/...
20 # 2. Other paths (including local and bluearc) are left unchanged.
22 # 3. Converted files written to standard output, one per line.
24 #----------------------------------------------------------------------
30 while [ $# -gt 0 ]; do
37 echo "file_to_url.sh [-h|--help]"
38 echo "file_to_url.sh <file1> <file2> ..."
39 echo "file_to_url.sh @<filelist>"
40 echo "cat <filelist> | file_to_url.sh"
44 # Other unknown options.
47 echo "Unknown option $1"
54 list=`echo $1 | cut -c2-`
55 if [ ! -f $list ]; then
56 echo "File list $list not found."
58 cat $list | while read file
60 echo $file | sed 's;^/pnfs/;root://fndca1.fnal.gov:1094/pnfs/fnal.gov/usr/;'
61 nfile=$(( $nfile + 1 ))
66 # Interpret anything as a file name.
70 echo $file | sed 's;^/pnfs/;root://fndca1.fnal.gov:1094/pnfs/fnal.gov/usr/;'
71 nfile=$(( $nfile + 1 ))
77 # Maybe read files from standard input.
79 if [ $nfile -eq 0 ]; then
82 echo $file | sed 's;^/pnfs/;root://fndca1.fnal.gov:1094/pnfs/fnal.gov/usr/;'
83 nfile=$(( $nfile + 1 ))