#!/usr/local/rexx/rxx /* * FN.REX * * The FN.REX external function accepts a file name in a * "system-independent" format (i.e., node:/fully/qualified/name) * and generates a local filename which will provide (probably * NFS based) access to the desired file. * * The syntax of FN.REX is * * fn * * where has the form * * host:/filename/on/that.host * * NOTE: If 'host:' is omitted, no translation is done, assuming * that a local filename was really specified in the first place. */ parse arg host ':' file call popen 'hostname' parse pull currenthost select when file="" /* if no "host:", parse will have put it all */ then o=host /* in host, and file will be null. */ when host=currenthost /* if explicitly referring to a file on this host */ then o=file /* just use that file name */ otherwise do call popen 'df' lm="" /* will become the saved df line that matchs. */ do while queued()>0 parse pull l parse var l dfhost ':' dfhostdir dfjunk '/' dflocaldir if length(dfhostdir)>0 , /* weeds out header and locals */ & dfhost==host /* weeds out other systems */ then do if dfhostdir=="/" /* for root file system */ then lm=l /* save this line in case we find no other */ else if left(file,length(dfhostdir))==dfhostdir /* right line? */ then do lm=l leave end end end if length(lm)>0 /* if we found something, */ then do parse var lm dfhost ':' dfhostdir dfjunk '/' dflocaldir if dfhostdir^=='/' /* if not root filesystem, */ then file=right(file,length(file)-length(dfhostdir)) /* trim rmt dir */ o='/'||dflocaldir||file /* add correct local dir */ end else do /* if we found nothing, fail with error message */ say 'sorry, no path from here to' host':'file return /* return with no value is a failure */ end end end return o /* non-failure return */