From: lbaxter AT smtp DOT primavera DOT com (Lincoln Baxter) Subject: Re: drag/drop args (was Re: Shell-Here Explorer) 4 Dec 1997 20:54:22 -0800 Message-ID: <9712048812.AA881263589.cygnus.gnu-win32@primavera.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="simple boundary" To: Cc: , , --simple boundary Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit From: Lincoln Baxter on 12/04/97 01:39 PM >>> I've been using perl for quite some time from a CMD script, but if I call it from BASH it can't find any of the files! Not true Look at the bashrc file I sent you! (and attached again) I use perl ALL THE TIME. (from bash) on NT Do you have the PERL5LIB and other environment vars set? ********* Do you have #!perl at the top of all your scripts?***************** ********* Are you calling the script with a pathname the INCLUDES the ..pl extenstion ? *********** BASH does not use the the PATHEXT winNT EV... (it would be nice if it did) but what the hell >>>The pathnames used by BASH cannot be understood by perl... If you are talking about the virtual mount paths OF COURSE... these are stored in the registry under a cynwyn key. No other tools know about them. If you are talk about the symlinks... OF COURSE... it would have been nice of WinNT has supported these, (They are JUST like unix symlinks in their contents)... bash understands them... it is too bad M$ didn't put this in. If you look at the .bashrc file you will notice that I create an environment var (EV) CDISK with represents the current disk that the virtual mount represents. When I use paths as arguements to winNT programs I use the $CDISK EV. Set the SetLocation and GoTo functions in the bashrc file I sent you. I strongly urge you to understand this .bashrc file... I spend ALOT of time on it... still am, it makes bash VERY usable in a NT environment >>>so does that mean I have to get a new version of perl which was compiled for use with gnu-win32 That is an interesting Idea... but it would be a generic unix port, without support the WINNT stuff like OLE automatic etc that NT perl does today. What I'd like is: for bash to understand how to convert ANSI terminal escape sequences for bold and reverse video, to the NT output formats so that scripts that use these would work like they do on unix. Also I'd also like, to know why it gets 'Out of queue slots!' messages during rm -rf and it would be nice to see the 'setgrent not implemented' messages go away... Lincoln (See attached file: lincoln.bashrc) (See attached file: .bashrc) --simple boundary Content-Type: text/plain; charset=US-ASCII; name="lincoln.bashrc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="lincoln.bashrc" # Here is an assortment of command line prompts. Choose one by # deleting or commenting-out all others. #PS1='[$PWD] ' PS1='$PWD ' #PS1='$($HOME\wd.pl)' #print device/directory default #PS1='$CDISK$CPATH ($PWV) ' #print device/directory default ( current clearcase view ) #PS1="$ " # a simple default prompt #PS1="!% " # prompt with history number #here is an assort more of EXPORTS that are use specific export PERL5LIB="$tls\perl\lib;$pll;$HOME/perl/lib" #export CDPATH=".;$pops;$tools;$clients" #export LEPATH="$HOME;$pops;$pscr;$plib;$cg;$bxp;$nsrc;" ### the EDITOR environment vaiable to my favorite editor export TERM=vt100 export EDITOR=c:/software/lemmy/lemmy.exe export TABS_AT=3 export COLUMNS=150 #how wide you want ls to format output SetLocation geno $srvr/Tools/GenObj SetLocation genf $srvr/Tools/GenFieldIDs SetLocation gnu $pkg/GNU-from-Cygnus SetLocation bxp $HOME/baxup export DBUSER=lincoln export DBPASS=lincoln unalias mmk function mmk { GoTo $mkd make DBUSER=$DBUSER DBPASS=$DBPASS CVTMMF= BODIR='\Pops\MinBusObj' $* } function extract { $HOME/baxup/transfer.pl -extract $* } function transfer { $HOME/baxup/transfer.pl $* } #Some make aliaes... a mmkn="( mmk nothing )" a mmkg="( mmk gen )" a mmkm="( mmk make )" a mmka="( mmk all )" a mktest="(GoTo $mkd; make register; make tarch)" a mm=mkmk a lepath="ppath \$LEPATH" a sm="$HOME/perl/lib/sendmail.pm -from lbaxter AT primavera DOT com" a om='omake -EN /I MAKE="omake -EN"' a omake='omake -EN /I MAKE="omake -EN"' a sql="sqlplus $DBUSER/$DBPASS AT POPS DOT world" a cache="echo \"\nVIEW CACHE:\n\"; cleartool getcache -view -cview; echo \"\nMVFS CACHE:\n\"; cleartool getcache -mvfs" a pcc="ping clearcase" alias sch2nuts="( cd $HOME/data; perl -I $HOME/perl/lib $HOME/perl/sch2nuts.pl; )" --simple boundary Content-Type: text/plain; charset=US-ASCII; name=".bashrc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=".bashrc" #!bash set posix set -o vi #use vi command line editing keys... emax is the other possibilty #set +x #set m + # turn off completion messages for backgrounded tasks echo "Executing .bashrc" ## ## setup your HOME enviroment var in unix format... ## If your home dir is not on c: I recommend that you create ## a softlink link on c: as follows ## ln -s HOMEDISK:/home /home ## Lincoln ## saved=`pwd` #exec a command line perl script by writting it to c:/temp first #provides equiv of perl -e in non-writeable directories... export BPERLLIB=$HOME export BPERL="perl -I $BPERLLIB" export TMP=c:/temp function perl_e { declare script=$1; shift echo "$script" > $TMP/$$.pl $BPERL $TMP/$$.pl $* rm -f $TMP/$$.pl } function lc { perl_e 'print lc $ARGV[0];' "$*" } function uc { perl_e 'print uc $ARGV[0];' "$*" } function lcfirst { perl_e 'print lcfirst $ARGV[0];' "$*" } function ucfirst { perl_e 'print ucfirst $ARGV[0];' "$*" } if test -z "$HOME_FIXED" ; then if home=$(perl_e '$h=$ARGV[0]; $h=~s@\\@/@g; print lc($h);' $HOME); then export HOME=$home export HROOT=$(echo $HOME | sed 's,/[A-Za-z]*$,,') export HROOTDIR=$(echo $HROOT | sed 's,^[A-Za-z]:,,') hname=$(hostname) hname=$(lc $hname) export HOSTNAME=$hname export HISTSIZE=300 export LUSERNAME=$(lc $USERNAME) export HOME_FIXED=1 alias whoami='echo $USERNAME' fi fi function make { nice -n 19 nmake /nologo $* } #mount the root of the home directory on /home if ! test -d $HROOTDIR; then mount $HROOT $HROOTDIR fi function start { cmd.exe /c start $* & } function windiff { start windiff $* } function diffp { cleartool diff -pred -gra $* & } function dfn { mount | egrep -v '/dev/| / |Device' | sort | sed 's,native.*,,' } function dfp { $BPERL $HOME/bash_df.pl } alias df=dfn function remount_views { $BPERL $HOME/bash_remount_text.pl > $TMP/$$.bsh . $TMP/$$.bsh rm -f $TMP/$$.bsh } remount_views function mount_all { declare script=$HOME/bash_mount_text.pl if test -x $script; then declare text=$($BPERL $script $*) declare file=/tmp/$$.tmp echo "$text" > $file . $file rm -rf $file df return 0; else echo "Could not find $script" return 1 fi } function umount_a { for d in $(df|awk '{ print $2}') ; do if ! test -d $d; then umount $d; fi ; done } #umount everything first... umount_a #and remount based on what we find... mount_all -alias alias ma="mount_all -alias" alias bm=mount_all #Fix up the path... #put . first on path so dos behavior happens.... if test -z "$INITIAL_PATH" ; then export INITIAL_PATH=$PATH export PATH=".:$INITIAL_PATH" fi # Aliases to mimic the standard command interpreters and access their # built-in commands. for dsk in a b c d e f g h i j k l m n o p q r s t u v w x y z do alias $dsk:="cd $dsk:/; " done export SWITCHAR=${SWITCHAR:=/} #now get some dos cmds defined for arg in at assoc doshelp cls copy del dir erase move path ren tree ver verify vol do alias $arg="cmd.exe ${SWITCHAR}c $arg" done function root_path { echo "$(pwd | sed 's,^\(/[^/]*\).*,\1,' )" } function SetPathEnv { export CDISK=$(root_path) } #export PROMPT_COMMAND=SetPathEnv #execute the above function before prompting... #bad idea... #### support for working at home #### implement fake cleartool commands such that #### real cleartool commands are written to the following file #### These commands can then be executing upon returning to work #### prior to coping the files modified at home into the VOB location export CTREMOTEFILE=$HOME/ct_cmds_from_home.bsh #### The at home cleartool support requires that you subst a drive:/path #### to M: and that your at work clearcase view is a directory under M: #### (just like it is at work) function at_home_lsview { ls -1 m:/ | awk '{ printf( "* %-30s \\\\labs_pc\\ViewStorage\\%s.vws\n" ,$1 ,$1 ); }' } function fake_cleartool #for at home { declare cmd=$1; if [ "$#" != "" ]; then shift ; fi case $cmd in lsview) at_home_lsview ;; pwv) root_path;; lsco) ;; catcs) ;; ls) ls -l $*|sed 's,$, Rule: (faked),';; co) at_home_checkout $* ;; ci) at_home_checkin $* ;; mkelem) at_home_mkelem $* ;; rmname) at_home_rmname $* ;; mv) at_home_ctmv $* ;; *) echo Faking cleartool $cmd $*;; esac return 0; } function at_home { test "$NOT_AT_WORK" = "1" } if at_home; then alias cleartool=fake_cleartool; fi function lsv { if ! at_home; then start cleartool lsvtree -gra $* else echo "You are not at work"; fi } export VOB_LIST="/Pops /Tools /Packages /Views" function lsco { cleartool lsco -cview -r $* } function cc_exec_ok { cat $1 echo -n "Ok execute the above with cleartool? [y/n] "; read a if test $a = y; then cat $1 | cleartool else echo "created $1" fi } function cilsc { if test $# -lt 1; then echo "Usage: arglist must atleast include a comment" return 1 fi declare cmt=$1; shift lsco -s $* | sed "s,^,ci -c \"$cmt\" ," > $TMP/$$.cc cc_exec_ok $TMP/$$.cc } function cils { lsco -s $* | sed "s,^,ci -nc ," > $TMP/$$.cc cc_exec_ok $TMP/$$.cc } alias lscoall='lsco $VOB_LIST' alias ciall='cils $VOB_LIST' function ddisk { if [ $# != 1 ]; then echo "Usage: ddisk disk" return 1 fi declare disk=$1 vname=$(mount | egrep -i "^$disk" | awk '{ print $2 }' | sed 's,^/,,' ) if [ "$vname" != "" ]; then cleartool endview $vname umount /$vname fi if at_home; then subst $disk /d; fi } function mount_view { if [ $# != 2 ]; then echo "Usage: mount_view disk: name" return 1 fi declare disk=$1 declare name=$2 declare slash='\' declare view=view echo "mounting $name on $disk" if at_home ; then subst $disk m:\\$name else cmd="net use $disk $slash$slash$view$slash$name" $cmd fi mount $disk/ /$name } function show_disk_map { if at_home ; then subst; else net use | grep OK; fi } function setview # view_name disk: { if [ $# != 2 ]; then echo "Usage: setview viewname disk:" return 1 fi declare vname=$1 declare disk=$( echo $2|sed 's/^\(.\).*/\1/' ): declare slash='\' view="view" if test -d $disk/; then show_disk_map echo -n "Ok to dismount $disk? [y/n] " ; read a if [ "$a" != "y" ]; then return 1; fi ddisk $disk fi if cleartool startview $vname ; then mount_view $disk $vname ##cd $disk/ declare av=$(echo $vname|sed s,$LUSERNAME\_,,) alias $av="m2v $vname" m2v $vname fi } function m2v { if [ $# -lt 1 ]; then echo "Usage: m2v viewname" return 1 fi #echo args=$* declare wd=$( echo $PWD | sed 's,/[^/]*,,' ) declare vname=$( df | grep -i "$1 " | awk '{print $1;}' ) #echo "wd=$wd vname=$vname" if test -d $vname/$wd; then cd $vname/$wd else cd $vname fi } function mkview { declare vname=$1 vname="$($LUSERNAME)_$vname" slash='\' hname=$(ucfirst $hname) storedir="ViewStorage" vpath="$slash$slash$hname$slash$storedir$slash$vname.vws" echo -n "Ok to make clearcase view: $vname in $vpath" read a; if [ "$a" != "y" ]; then return; fi cmd="mkview -tag $vname $vpath" if echo $cmd | cleartool ; then if [ "$2" != "" ]; then setview $vname $2 fi fi } function lsview { if [ "$1" = "" ]; then cleartool lsview else cleartool lsview | grep -i $1 fi } function rmview { declare vname=$1 slash='\' if cleartool lsview | grep $vname; then drive=$(net use|grep $vname|sed 's,\([A-Z]:\).*,\1,') if [ "$drive" != "" ]; then mntOn="(mounted on $drive)"; else mntOn="(Not Mounted)" ; fi echo -n "Ok to remove view: $vname $mntOn " read a; if [ "$a" != "y" ]; then return; fi cmd="cleartool rmview -tag $vname -force" if [ "$drive" != "" ]; then net use $drive /delete; fi if $cmd; then echo "$ClearCase view $vname was removed"; fi fi } function at_home_pushd { declare here=$( echo $PWD|sed 's,/[A-Za-z_]*,\$CDISK,' ) echo Working in: $here echo "pushd $here" >> $CTREMOTEFILE #echo $here } function at_home_popd { echo 'popd' >> $CTREMOTEFILE } function at_home_rmname { at_home_pushd echo "Will: cleartool rmname $*" echo " cleartool rmname $*" >> $CTREMOTEFILE at_home_popd } function at_home_ctmv { at_home_pushd echo "Will: cleartool mv $*" echo " cleartool mv $*" >> $CTREMOTEFILE at_home_popd } function at_home_mkelem { declare here=$(at_home_pushd) echo "echo -n Need to create elements for $* ... Ok to continue ; read a" >> $CTREMOTEFILE echo 'if [ $a = y ]; then' >> $CTREMOTEFILE echo " cleartool co ." >> $CTREMOTEFILE for f in $*; do if test -e $f; then echo "Will: cleartool mkelem -nc $f" echo " if test -r $f; then echo found existing $fi;echo will try to check $f out; cleartool co -nc $f;" >> $CTREMOTEFILE echo " else echo creating $f; touch $f; cleartool mkelem -nc $f; fi" >> $CTREMOTEFILE else echo "Could not find $f" fi done echo "fi">> $CTREMOTEFILE at_home_popd } function at_home_checkin { at_home_pushd for f in $*; do echo "Will: cleartool ci -nc $f" echo " cleartool ci -nc $f" >> $CTREMOTEFILE done at_home_popd } function ichmod #chmod silently ignoring files that do not exist { declare prot=$1; shift; for f in $*; do if test -f $f; then chmod $prot $f; fi done } function at_home_checkout { at_home_pushd ichmod +w $* echo "Will: cleartool co $*" echo " cleartool co $*" >> $CTREMOTEFILE at_home_popd } #raw cp... incase you aliased cp=cpa function _cp { cp.exe $* } ### Global Search and Replace from a sed file function gsr_ff { if test $# -le 1; then echo "Usage: gsr_ff sed_file files" return 1 fi declare sed_file=$1; shift; if ! test -r $sed_file; then echo "Could not find sed file: $sed_file" return 1 fi declare save_dir=gsr_save_$$ declare ans=n if test -e $save_dir; then ls $save_dir/* echo -n "$save_dir exists with above files in it; OK to remove? [y/n] "; read ans; if [ $ans = n ]; then return 1; fi rm -rf $save_dir fi ans=n cat $sed_file echo "Will make the above replacements in $*" echo "Will save original files in $save_dir" declare f="" mkdir $save_dir for f in $*; do if [ ! -d $f ]; then echo "Working on $f..." cp $f $save_dir/$f cat $f | sed -f $sed_file > $f.tmp if ! diff $f $f.tmp ; then if [ "$ans" != "a" ] ; then echo -n "Ok to mv $f.tmp to $f [y/n/a/q] "; read ans; ans=$(lc $ans) fi if [ "$ans" = "q" ]; then return 1; fi if [ "$ans" = "y" -o "$ans" = "a" ]; then mv $f.tmp $f; fi else rm -f $save_dir/$f fi fi rm -f $f.tmp done ls $save_dir/* echo -n "Ok to remove the above originals of the files modified? [y/n] "; read ans; if [ "$ans" = "y" ]; then rm -rf $save_dir; fi } ### Global Search and Replace function gsr { if test $# -le 2; then echo "Usage: gsr findexp replace_str files" return 1 fi find=$1; shift; replace=$1; shift; echo "finding:/$find/ ,replacing with /$replace/ in $*" cat > $$.sed < $f.tmp mv $f.tmp $f fi done } function detab { tab expand $* } function entab { tab unexpand $* } function find_readable_file { echo "In find_readable_file" declare f=$1 declare d for d in $(echo $LEPATH | sed 's,;, ,g'); do #echo "testing $d/$f" if test -r $d/$f; then echo "$d/$f" return 0 fi done return 1 } function edit_file { #for bash compatibility on nt declare file=$1; file=$(echo $file| sed 's,//\(.\),\1:,') echo "Editing $file" start $EDITOR "$file" } function lep { rm -f $TMP/$$.txt while read line; do echo "$line" >> $TMP/$$.txt; done le $TMP/$$.txt } function le { declare f while [ "$1" != "" ]; do if test -r $1; then edit_file $1 else f=$(find_readable_file $1) if [ "$?" = "0" ]; then echo Editing $f edit_file $f else echo "Could not find $1 in: \$LEPATH" echo "touch $f first" fi fi shift done } function ppath { echo "" for d in $(echo "$1" | sed "s,;, ,g"); do echo $d; done echo "" } function lower_pipe { while read line; do echo $(lc $line); done } function stat { stv=$? if [ $stv = 0 ]; then echo "Success" else echo "Error: $stv" fi } function PathIsRelative { echo $1|egrep -q '^\.\.' } function cd { if [ "$1" != "-" ]; then if ! test -d $1; then echo "$1 does not exist"; return 1; fi fi builtin cd $1 SetPathEnv } function findmerge { if [ $# -lt 3 ]; then echo "findmerge Path Version merge|print" return 1 fi declare what="$1"; shift declare ver="$2"; shift cleartool findmerge $what -fver $ver -nc -$* } alias fm=findmerge function ci { if [ $# -lt 1 ]; then echo "Usage: $0 files" return 1 fi cleartool ci $* } function co { if [ $# -lt 1 ]; then echo "Usage $0 files" return 1 fi cleartool co $* } function cci { if [ $# -lt 2 ]; then echo "Usage: $0 comment files" return 1 fi declare comment=$1; shift ci "-c \"$comment\"" $* } function cco { if [ $# -lt 2 ]; then echo "Usage: $0 comment files" return 1 fi declare comment=$1; shift co "-c \"$comment\"" $* } function lco { if ! co $*; then return 1; fi; le $* } function lcco { declare cmt=$1; shift; if ! cco "$cmt" $*; then return 1; fi; shift; le $* } #compile args using project makefile obj target... function clean { make clean } function mcc { for m in $*; do #echo "Executing make obj MODULE=$m" make obj MODULE=$m; done } function mkmk { for f in $*; do perl -I /Tools/PerlLibs /Tools/PerlScripts/makemake.pl -libdir /Pops/lib -bindir /Pops/bin /Pops/Generated/prj/$f.prj; done } #Locations... function GoTo { if test -d $1; then builtin cd $1 else builtin cd $CDISK$1 fi SetPathEnv } function SetLocation { declare lnm=$1 declare pth=$2 export $lnm=$pth alias $lnm="GoTo $pth" } SetLocation pops /Pops SetLocation tls /Tools SetLocation pomgr /pomgr SetLocation views /Views SetLocation esp /Esp SetLocation pkg /Packages SetLocation plib $tls/PerlLibs SetLocation pscr $tls/PerlScripts SetLocation tmkd $tls/Make SetLocation cg $tls/CodeGen SetLocation mkd $pops/Make SetLocation bin $pops/bin SetLocation server $pops/Server/main SetLocation proxy $pops/Proxy/main SetLocation sched $pops/Services/Scheduler SetLocation bod $pops/BusObj/mmf SetLocation cmn $pops/Common SetLocation min $pops/MinBusObj/mmf SetLocation isd $pops/InfraStructure/mmf SetLocation dki $pops/DevKit/include SetLocation gen $pops/Generated for trg in icpp cpp pcpp pdl h uh ih ch sh ph pom oracle ra msg prj; do SetLocation g$trg $gen/$trg done SetLocation sinc $gen/sinclude SetLocation pinc $gen/pinclude SetLocation cinc $gen/cinclude SetLocation cvt $pops/conversion SetLocation cvtm $cvt/main SetLocation cvtp $cvt/P3V2 SetLocation clients $pops/Clients SetLocation bhs $clients/BoatHouse SetLocation ra $clients/RA SetLocation regw $clients/pabst/Windows SetLocation regp $clients/pabst/CmdLine SetLocation regc $clients/pabst/Common ### common aliases... alias a="alias -x" a register="make register" a r="fc -s" a tar="tar --force-local " a ..="cd .." a ...="cd ../.." a ....="cd ../../.." a .....="cd ../../../.." a cdpath="ppath \$CDPATH" a lsd="ls -F | grep /" a vi=le a ll="ls -al" a lsf="ls -F" a lsa="ls -aF" a t="cat" a lart="ls -lart" a brc=". $HOME/.bashrc" a erc="le $HOME/.bashrc" a cmd="start cmd.exe"; a h=history a ie='"c:/Program Files/Plus!/Microsoft Internet/iexplore.exe"' a p2h='perl $CDISK/Tools/PerlScripts/pod2html.pl' a sql="cmd.exe /c sqlplus $USERNAME/$USERNAME AT POPS DOT world" #a vdiffwu="vdiff32 generated/pcpp/pworkunit.cpp generated.save/pcpp/pworkunit.cpp" ### Cleartool aliases a ct=cleartool a label="cleartool mklabel -replace" a pwv="cleartool pwv" a catcs="cleartool catcs" a lsh="cleartool lshistory" a ctls="cleartool ls" a unco="cleartool unco" a lspriv="cleartool lsprivate | grep -v -E 'Debug|Generated|DevKit|\.lib|\.exe|\.exe|\.mki|\.dll'" a H="cd ../Helpers" a I="cd ../include" a make="make DBUSER=$USERNAME DBPASS=$USERNAME" a mmk="make DBUSER=$USERNAME DBPASS=$USERNAME CVTMMF= BODIR='\\Pops\\MinBusObj'" export PERL5LIB="$tls\perl\lib;$pll;$HOME/perl/lib;$HOME" export CDPATH=".;$pops;$tls;$clients" export LEPATH="$HOME;$pops;$pscr;$plib;$cg;$bxp;$nsrc;" userrc="$(lc $HOME/$USERNAME.bashrc )" if test -f $userrc; then source $userrc; else cat <