PDA

View Full Version : [SOLVED] sh script, bad substitution



8Kuula
May 6th, 2010, 01:06 PM
Script css-update-mapcycle:

#! /bin/sh

cd ~/srcds-cs/cstrike/maps

rm ../mapcycle.txt

MAPS=`ls -1 *.bsp`

for name in $MAPS
do
echo ${name/.bsp/} >> ../mapcycle.txt
done


executing:


bunbun@gatekeeper:~/scripts# ./css-update-mapcycle
./css-update-maplist: 12: Bad substitution


So what is wrong? Script worked fine in Debian 5.0 but not with ubuntu server 10.04.

Portmanteaufu
May 6th, 2010, 02:40 PM
The difference between OSs might be your shebang line. In Ubuntu, if I recall correctly, /bin/sh is a soft-link to "dash", a shell that is similar to but different from "bash". In Debian, /bin/sh probably points to regular bash.

I don't have access to a shell at the moment, so I'm afraid I can't check whether this fixes it for you. Just replace your first line with

#!/bin/bash and give that a run.

8Kuula
May 6th, 2010, 04:36 PM
yes, works now, thanks :)

torgbaskar
March 16th, 2011, 12:42 PM
yes, works now, thanks :)

it works for me, thanks !