Home

Main
FSP Servers
FSP Software
FSP Downloads

FSP project
FSP Team
Testers needed
Open tasks
Wizards vs CSH

Mailing lists
Bug Tracker

FSP Documents
Purpose
History
Articles
Today
Future
INFO
FAQ Old | New
FSP Protocol
Quotes

FSP suite
Browse Code
Copyright
Changelog
TODO
Open Hub page

Java library
Browse Code
API
READ.ME
Changelog
Open Hub Page

FSP C library
Browse Code
README
NEWS
Changes
TODO
Open Hub page

FSP proxy
Browse Code
READ.ME
Changelog

PyFSP
Browse Code

FSP entry in
GNU dir
Wikipedia

My projects
FSP Client
Download Machine
Smart Cache
SC Loader
Old programs

SF Logo

Porting FSP setup script from CSH to BASH

One of annoying problem is that sample shell script for setting aliases for FSP commands is in CSH and there is large group of people using Bash or Zsh. CSH and TCSH works okay with this script, but not bourne shells.

Our litle C-shell problem is here, look at him. It looks a very simple, isn’t it? I have tried to port it from CSH to KSH in 1995. After many unsucessfull tries and consultation with our local Unix gurus, i was still unable to do aliases with arguments in bourne shell. I was defeated, so I have switched my shell to csh everytime when i needed to use FSP.

I have failed again in around 2000 when i have released fsp281b4 and 3 years later when i have released b5. Because announcing FSP on freshmeat attracts some interest to this project, i have asked people if they can help with this task.

Where is the problem?

Everybody knows that setenv = export. Real problem is that aliases in CSH can take arguments, but this is not possible in bash. See some words of wisdom from Hoaxter: (quoted from FSP mailing list)

I see the real prob with this after reading the csh stuf more carefully Form the bash manual: There is no mechanism for using arguments in the replacement text, as in csh. If arguments are needed, a shell function should be used (see section 3.3 Shell Functions). Bash reference

What needs to be done

User type fls *.c. Shell function should call command: flscmd *.c (wildcards must not be expanded, they will be expanded by remote server)

Help me!!!

After so many unsuccesfull tries i have placed request for help on FSP home page. About 2 months nobody was interrested in porting this little script. Then …

and here comes a new challenger!

Radim Kolar - Jun 2003 alias fcat (set noglob; exec fcatcmd !*)

Ben Mesander - 21 Aug 2003 alias “fcat=exec fcatcmd *”

Hoaxter - 21 Aug 2003

fcommandlist="fcat fcd fdu ffind fget fgrab fhost fless fls fmore fpro fpwd frm
frmdir ftouch"

for x in $fcommandlist
do
        alias $x=$x"cmd"
        echo "added alias $x for command $xcmd"
done

Hoaxter - Downloaded from http://sven.stormbind.net/fsp/setup.bash - File last mod date: 21 Aug 2003

fcommandlist="fcat fdu ffind fls fget fgrab fpro frm frmdir"

for x in $fcommandlist
do
        alias $x=$x"cmd"
done
function fcd() {
        fcdcmd $1
        export FSP_DIR=$(fcdcmd 2>1 $1|grep '^/')
}
function ftouch() {
        touch $1
        fput $1
        rm $1
}
function fpwd() {
        echo "$FSP_HOST $FSP_PORT : $FSP_DIR"
}
function fless() {
        fgetcmd $1
        less $1
        rm $1
}
function fmore() {
        fgetcmd $1
        more $1
        rm $1
}

Bruno Ratnieks - 27 Aug 2003 alias fcat=’(set noglob;exec fcatcmd !*)’

Humberto Massa - 27 Aug 2003 fcat() { (set -f; exec fcatcmd “$@") }

Randy Chamberlin - 27 Aug 2003 alias fcat=’(set noglob; exec fcatcmd !*)’

Luis Ot?vio de Colla Furquim - 3 Sep 2003

#!/bin/sh

read cmd

while [ "$cmd" != "logout" ] ;
do
   a=`echo $cmd | /bin/cut -f 1 -d " "`
   if [ "`echo fcat fdu ffind fls fget fgrab fpro frm frmdir | /bin/grep $a`" ==+"fcat fdu ffind fls fget fgrab fpro frm frmdir" ] ;
   then
      exec "$cmd"
   else
      exec $cmd
   fi
   read cmd
done

And winner is!!

Hanno Hecker - 4 Sep 2003

_fcat () {
  flscmd "$@"
    set +f
 }
alias fcat='set -f; _fcat'

Enjoy Final result.