Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Script portability problem

  • 31-08-2004 4:18pm
    #1
    Registered Users, Registered Users 2 Posts: 3,958 ✭✭✭


    Iv made a script that i would like to use on several different types of unix,
    perticularly linux and aix.
    The problem is the script is a bash script and the location of the bash shell executable is in different locations i.e. /bin/bash (linux) /usr/local/bin/bash aix..
    so every time i change platform i have to manually edit the script

    it seems that all of the shell executables are in different places on both systems.
    so using a different shell would make no difference..:confused:

    is there a solution to this?
    i was thinking, is there some sort of none shell script that could edit these files when im installing the script?

    any suggestions appreciated,
    thanks :D


Comments

  • Registered Users, Registered Users 2 Posts: 3,284 ✭✭✭dubhthach


    Iv made a script that i would like to use on several different types of unix,
    perticularly linux and aix.
    The problem is the script is a bash script and the location of the bash shell executable is in different locations i.e. /bin/bash (linux) /usr/local/bin/bash aix..
    so every time i change platform i have to manually edit the script

    it seems that all of the shell executables are in different places on both systems.
    so using a different shell would make no difference..:confused:

    is there a solution to this?
    i was thinking, is there some sort of none shell script that could edit these files when im installing the script?

    any suggestions appreciated,
    thanks :D

    Well you could always use /bin/sh (bourne shell) which is a default on all unix systems the only issue is that bash (bourne again shell) has features that the standard bourne shell doesn't. Either that or create a softlink on the AIX system at /bin/bash that points to /usr/local/bin/bash


  • Registered Users, Registered Users 2 Posts: 2,077 ✭✭✭parasite


    couldn't you just use the $BASH variable ?


  • Registered Users, Registered Users 2 Posts: 3,958 ✭✭✭Chad ghostal


    nice one dubhthach i dont know why it didnt occur to me to use /bin/sh..
    itll take a bit of changing but it should work. :confused::)

    parasite the $BASH variable doesnt seem to have a value on aix,
    its just blank .. :confused:

    thanks lads


  • Closed Accounts Posts: 96 ✭✭krinDar


    nice one dubhthach i dont know why it didnt occur to me to use /bin/sh..

    Indeed, best practise is to use /bin/sh. Are you guaranteed that bash is
    on every AIX machine or do you just have an admin who cannot use
    anything else and therefore you assume it will be on every machine ?

    You could also do:
    #!/usr/bin/env bash

    which will look up bash in the path of the user who is running the script.
    This would depend on two things however, bash being installed, and it
    being in their path.
    parasite the $BASH variable doesnt seem to have a value on aix,
    its just blank ..

    I think he is refering to the fact that it is set to the full filename of
    bash ... but only when you are running bash.


  • Registered Users, Registered Users 2 Posts: 3,284 ✭✭✭dubhthach



    parasite the $BASH variable doesnt seem to have a value on aix,
    its just blank .. :confused:

    You could set it i'm not sure about in AIX but in IRIX i would go
    setenv BASH /usr/freeware/bin/bash (or something like that- it's been awhile i tend to use tcsh) but as krinDar said it's always best to stay with /bin/sh it's guaranteed to be present in all *nixes though on Linux it's always a soft link to bash anyways
    :rolleyes:


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 3,958 ✭✭✭Chad ghostal


    krinDar wrote:
    Indeed, best practise is to use /bin/sh. Are you guaranteed that bash is
    on every AIX machine or do you just have an admin who cannot use
    anything else and therefore you assume it will be on every machine ?

    well its me making the scripts and i already wrote them in bash,
    i just assumed bash would be installed everywhere :rolleyes:
    i guess ill just make any changes that are needed and learn my lesson.. :(

    thanks again lads :D


  • Registered Users, Registered Users 2 Posts: 4,676 ✭✭✭Gavin


    well its me making the scripts and i already wrote them in bash,
    i just assumed bash would be installed everywhere :rolleyes:
    i guess ill just make any changes that are needed and learn my lesson.. :(

    thanks again lads :D

    you could also try ksh. I wrote scripts for aix/solaris and both had ksh, which has more scripting capabilities than sh.

    Gav


Advertisement