Probleme de commandes shell

Résolu
OS : mandrake 10.1

salut,

j'ai un probleme avec mes commandes shell; Le fait d'ecrire mes variable d'envorinnement sous la forme $(nom_de_la_variable), me renvoit des messages d'erreur; Alors quand je les ecris sous la forme $nom_de_la_variable ca marche.

aussi pour l'affectation des valeurs a des variables, je ne peux pas les ecrire sous cette forme LIBS = -lOB -lJTC -lpthread -ldl il faut absolument les mettre entre cotes LIBS = "-lOB -lJTC -lpthread -ldl".

le probleme est que tous les Makefile (presque) s'ecrivent dans la premiere forme, et je suis obligé a chaque fois de les modifier.

SOS!!!!

merci

6 réponses

  1. Modérateur
    Salut
    sous bash, la construction
    $(toto p1 p2)
    correspond à l'output de l'exécutable ou commande toto avec les paramètres p1 et p2
    ${ma_variable} est un équivalent de $ma_variable
    johand@horus:~/tmp$ echo $(ls)
    bidon.lyx episode1.mp3 epreuve_integree-grand01.lyx fond-apt.jpg fond-config-base.jpg fond-etude-cas.jpg fond-existant.jpg fond-installation.jpg fond-plus-loin.jpg fond-pouce.jpg fond-pres-debian.jpg fond-src-info.jpg josee log.sxw p3130021.jpg
    johand@horus:~/tmp$ ls='zut'
    johand@horus:~/tmp$ echo ${ls}
    zut
    


    Un makefile est un makefile, pas un script shell !
    1
    1. Modérateur
      Tu verras l'intérêt des guillemets le jour où tu écriras ceci
      johand@horus:~/tmp$ touch truc
      johand@horus:~/tmp$ MYVAR="xyz rm truc"
      johand@horus:~/tmp$ ls truc
      truc
      johand@horus:~/tmp$ MYVAR=xyz rm truc
      johand@horus:~/tmp$ ls truc
      ls: truc: No such file or directory
      
      Encore plus amusant avec 
      
      echo "/ fR- mr"|rev 
      (surtout en root ;DDD </pre></pre>
      1
      1. deja, merci bcp pour l'info.
        pour plus d'explications, j'ai un tas de makefiles de compilation a executer il sont tous dans le genre:
        SHELL = /bin/sh

        top_srcdir = ..

        SERVER_NAME = server
        CLIENT_NAME = client

        TARGETS = $SERVER_NAME\
        $CLIENT_NAME

        include $top_srcdir/config/Make.rules

        COMMON_OBJS = NamingExample.o

        SERVER_OBJS = Server.o\
        NamingExample_skel.o

        CLIENT_OBJS = Client.o

        SRCS = $(COMMON_OBJS:.o=.cpp) \
        $(SERVER_OBJS:.o=.cpp) \
        $(CLIENT_OBJS:.o=.cpp)

        ALL_CXXFLAGS = $CXXFLAGS
        ALL_CPPFLAGS = "-I. -I$top_srcdir/include $OB_CPPFLAGS $CPPFLAGS"
        ALL_LDFLAGS = "-L$top_srcdir/lib $OB_LDFLAGS $LDFLAGS"
        ALL_LIBS = "-lCosNaming $OB_LIBS $LIBS"

        $(SERVER_NAME): $(COMMON_OBJS) $(SERVER_OBJS)
        rm -f $@
        $(CXX) $(ALL_CXXFLAGS) $(ALL_LDFLAGS) -o $@ \
        $(COMMON_OBJS) $(SERVER_OBJS) $(ALL_LIBS)

        $(CLIENT_NAME): $(COMMON_OBJS) $(CLIENT_OBJS)
        rm -f $@
        $(CXX) $(ALL_CXXFLAGS) $(ALL_LDFLAGS) -o $@ \
        $(COMMON_OBJS) $(CLIENT_OBJS) $(ALL_LIBS)

        NamingExample.cpp NamingExample.h: NamingExample.idl
        rm -f NamingExample.cpp NamingExample.h
        rm -f NamingExample_skel.cpp NamingExample_skel.h
        $(IDL) --no-type-codes NamingExample.idl

        NamingExample_skel.cpp NamingExample_skel.h: NamingExample.cpp

        include .depend

        en executant par exemple celui la,
        [trancely@localhost demo]$ ./Makefile

        je me retrouve avec les erreurs suivantes:

        ./Makefile: line 11: SHELL: command not found
        ./Makefile: line 15: top_srcdir: command not found
        ./Makefile: line 17: SERVER_NAME: command not found
        ./Makefile: line 18: CLIENT_NAME: command not found
        ./Makefile: line 20: TARGETS: command not found
        ./Makefile: line 24: include: command not found
        ./Makefile: line 26: COMMON_OBJS: command not found
        ./Makefile: line 28: SERVER_OBJS: command not found
        ./Makefile: line 31: CLIENT_OBJS: command not found
        ./Makefile: line 1: COMMON_OBJS:.o=.cpp: command not found
        ./Makefile: line 1: SERVER_OBJS:.o=.cpp: command not found
        ./Makefile: line 1: CLIENT_OBJS:.o=.cpp: command not found
        ./Makefile: line 33: SRCS: command not found
        ./Makefile: line 37: ALL_CXXFLAGS: command not found
        ./Makefile: line 38: ALL_CPPFLAGS: command not found
        ./Makefile: line 39: ALL_LDFLAGS: command not found
        ./Makefile: line 40: ALL_LIBS: command not found
        ./Makefile: line 1: SERVER_NAME: command not found
        ./Makefile: line 1: COMMON_OBJS: command not found
        ./Makefile: line 1: SERVER_OBJS: command not found
        ./Makefile: line 1: CXX: command not found
        ./Makefile: line 1: ALL_CXXFLAGS: command not found
        ./Makefile: line 1: ALL_LDFLAGS: command not found
        ./Makefile: line 1: COMMON_OBJS: command not found
        ./Makefile: line 1: SERVER_OBJS: command not found
        ./Makefile: line 1: ALL_LIBS: command not found
        ./Makefile: line 44: -o: command not found
        ./Makefile: line 1: CLIENT_NAME: command not found
        ./Makefile: line 1: COMMON_OBJS: command not found
        ./Makefile: line 1: CLIENT_OBJS: command not found
        ./Makefile: line 1: CXX: command not found
        ./Makefile: line 1: ALL_CXXFLAGS: command not found
        ./Makefile: line 1: ALL_LDFLAGS: command not found
        ./Makefile: line 1: COMMON_OBJS: command not found
        ./Makefile: line 1: CLIENT_OBJS: command not found
        ./Makefile: line 1: ALL_LIBS: command not found
        ./Makefile: line 49: -o: command not found
        ./Makefile: line 52: NamingExample.cpp: command not found
        ./Makefile: line 1: IDL: command not found
        ./Makefile: line 55: --no-type-codes: command not found
        ./Makefile: line 57: NamingExample_skel.cpp: command not found
        ./Makefile: line 59: include: command not found
        0
        1. Modérateur
          Makefile n'est pas un exécutable mais un ensemble de règles de construction et de dépendances
          Normalement avec (GNU)make il suffit de lancer un simple
          make

          Lire la man page de make !!!
          exemple
          johand@horus:~/src/test$ ls
          Makefile
          johand@horus:~/src/test$ cat Makefile
          all: upper
          
          upper:montexte
                  tr 'a-z' 'A-Z' <montexte > upper
          montexte:
                  echo "Hello world" > montexte
          clean:
                  rm montexte upper
          
          
          johand@horus:~/src/test$ make
          echo "Hello world" > montexte
          tr 'a-z' 'A-Z' <montexte > upper
          johand@horus:~/src/test$ make clean
          rm montexte upper
          johand@horus:~/src/test$ ls
          Makefile
          


          Tiens, ganesha se trouve ici...
          0
          1. merci enormement pour ton aide.
            mnt j'ai compri le principe!!! ;)
            0