scoonma Posted October 3, 2007 Report Share Posted October 3, 2007 (edited) Hi folks, after several years without practice (and being quite a newbie with Linux in particular) I'm trying to create some useful shell script. It is a very early version yet. The aim is to split a given text file into numbered blocks ready to pass on as SMS to mobiles. I've never gotten below line 27 within the script during execution (sometimes halfway working with minor changes, but writing to stdout instead of using the given variable), and the bloody thing hits me at last with the following error: "../smsformat.sh: line 27: strcat: command not found" Please see below: ! /bin/bash # Purpose: Format given text from file to subsequent blocks ready for SMS sending # Usage: smsformat -i <infile> -l <smslength> -o <outfile> # or smsformat --help for short help help() { echo "Usage $0 -i <infile> -l <length> -o <outfile>" } if [ $# -lt 1 ]; then help fi while getopts i:l:o opt do INTEXT="" case "$opt" in i) INFILE=$OPTARG if [ -f $INFILE ] && [ -s $INFILE ] then cat $INFILE | while read line do INLINE=$line INTEXT=eval strcat $INTEXT $INLINE done fi;; l) if [ $OPTARG -gt 0 ] then LEN=$OPTARG fi;; o) OUTFILE=$OPTARG;; *) help;; esac done echo Tracepoint echo $INTEXT HELPTEXT1='eval tr -s '\n' $INTEXT' HELPTEXT2='eval tr -s '\r' $HELPTEXT1' HELPTEXT3='eval tr -s '\n' '[:space:]' $HELPTEXT2' # echo $HELPTEXT3 exit 0 Requesting your skilled comments, scoonma Edited October 4, 2007 by scoonma Quote Link to comment Share on other sites More sharing options...
neddie Posted October 4, 2007 Report Share Posted October 4, 2007 You've already seen the error message "strcat: command not found" - that's because strcat is a C function, not a bash function. Instead of INTEXT=eval strcat $INTEXT $INLINE just do a simple concatenation: INTEXT=$INTEXT$INLINE Personally I'd keep the file reading stuff out of that while loop to make it clearer, but I guess it doesn't matter. By the way, you have seen the "split" function, haven't you (man split) - doesn't that do what you want? Quote Link to comment Share on other sites More sharing options...
scoonma Posted October 4, 2007 Author Report Share Posted October 4, 2007 Ah, thanks neddie, I've spent hours looking for some explicit concatenation "function". Didn't know it was that simple. I'll also go on with split. Great! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.