Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #166765

Script doesn't work when it is run using '#!/bin/sh'

From Aero Maxx <aero.maxx.d@gmail.com>
Newsgroups linux.debian.user
Subject Script doesn't work when it is run using '#!/bin/sh'
Date 2016-04-16 14:30 +0200
Message-ID <roxwl-3jH-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


I have a number of bash scripts that work perfectly fine on fedora 23, 
but do not work on debian 8.  I've tried to sort it out myself, but am a 
little stuck now hopefully someone is able to give me a nudge in the 
right direction.

Ideally I would like them to work on both.

On Fedora 23
> $ ls -l /bin/sh
> lrwxrwxrwx. 1 root root 4 Jan 11 11:02 /bin/sh -> bash
> $ echo ${BASH_VERSION%%[^0-9.]*}
> 4.3.42

On Debian 8
> $ ls -l /bin/sh
> lrwxrwxrwx 1 root root 4 Nov  8  2014 /bin/sh -> dash
> $ echo ${BASH_VERSION%%[^0-9.]*}
> 4.3.30

As I discovered they weren't using the same bash, so I changed over my 
scripts to use #!/bin/bash and thought my problem would be solved, this 
doesn't seem to be the case, some errors have gone but some still remain.

I have shortened the script and pasted it below, its the IF part which 
is failing on debian 8.

> #!/bin/bash
>
> clear;
> devSite="/home/admin/web/";
>
> for domainDir in $(find ${devSite} -maxdepth 1 -type d); do
>
>     if [[ $domainDir == $devSite || $(basename ${domainDir}) == 
> 'site1' || $(basename ${domainDir}) == 'site2' ]]; then continue; fi;
>
>     echo "";
>     echo "Setting current directory to '$(basename ${domainDir})' web 
> public folder.";
>     cd ${domainDir}/web/public;
>
> done;

The output I get from the above script is
> wordpress_beta.sh: 8: bashtest.sh: [[: not found
> wordpress_beta.sh: 8: bashtest.sh: web: not found
> wordpress_beta.sh: 8: bashtest.sh: web: not found
>
> Setting current directory to 'web' web public folder.


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Back to linux.debian.user | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Script doesn't work when it is run using '#!/bin/sh' Aero Maxx <aero.maxx.d@gmail.com> - 2016-04-16 14:30 +0200
  Re: Script doesn't work when it is run using '#!/bin/sh' <tomas@tuxteam.de> - 2016-04-16 15:10 +0200
    Re: Script doesn't work when it is run using '#!/bin/sh' David Wright <deblis@lionunicorn.co.uk> - 2016-04-16 16:20 +0200
    Re: Script doesn't work when it is run using '#!/bin/sh' "Thomas Schmitt" <scdbackup@gmx.net> - 2016-04-16 16:30 +0200
    Re: Script doesn't work when it is run using '#!/bin/sh' Aero Maxx <aero.maxx.d@gmail.com> - 2016-04-16 16:50 +0200
      Re: Script doesn't work when it is run using '#!/bin/sh' Gene Heskett <gheskett@shentel.net> - 2016-04-16 17:40 +0200
        Re: Script doesn't work when it is run using '#!/bin/sh' Jeremy Nicoll <jn.ml.dbn.25@letterboxes.org> - 2016-04-16 22:40 +0200
          Re: Script doesn't work when it is run using '#!/bin/sh' Gene Heskett <gheskett@shentel.net> - 2016-04-17 01:20 +0200
      Re: Script doesn't work when it is run using '#!/bin/sh' <tomas@tuxteam.de> - 2016-04-17 18:00 +0200

csiph-web