Search code examples
bashchroot

bash rematch as chroot


I'm using this in my script and it works fine on my root server and on some others I tested.

But there's a problem when using it on my webhosting (Hosted Plesk): The chrooted shell, it doesn't output anything. Just quits. My webhoster said I need to use the absolute paths, but I dont know how to apply this on the bash rematch.

#!/bin/bash 
str='"<result="Abc1234" />"'
regex='<result="([0-9a-zA-Z._-/:]*)" />'
[[ $str =~ $regex ]] && echo ${BASH_REMATCH[1]}

(My first post here, sorry if I forgot something or misformatted this whole post)


Solution

  • In the discussion below the question it turned out that the issue is related to different default locales on the servers. Make sure that you are running the command with the right locale:

    LANG=en_US.UTF-8 bash script.sh
    

    (en_US.UTF-8) turned out to be the right locale in your case.


    PS: Please also keep in mind what Ondrej K. says.