*.bat file under Linux

Solved
Hello,

I've been writing Batch scripts on Windows for a while and I want to do the same on Linux. Let me explain:

On Windows, I create *.bat files that are interpreted by the console. I would like to create a file interpreted by the Linux console that has an icon on my desktop (Linux) and I just have to click on it to "execute" it (or launch it from the console).

On Windows, it's very simple: you open a text editor, write your script, and save it as a *.bat file.
But I have no idea how to do this on Linux.
Configuration: Windows XP Firefox 3.0.3

21 answers

  1. ./test.bat
    4
    1. Sorry TY I haven't been here for a long time

      could you tell us how you did it?
      0
      1. It's all good, I've solved the problem, thanks anyway. :)
        2


        1. #!/lib/modules/2.6.12-12mdk
          depmod -a
          #!/lib/modules/2.6.12-12mdk/comedi/drivers
          modprobe ni_pcimio
          comedi_config /dev/comedi0 ni_pcimio
          exit

          I'm not sure if it’s correct, but I primarily have a permission issue.
          0
          1. At the same time, the easiest thing would be for you to send us your script directly, we could correct it more easily!
            0
            1. -Execution of the bat: ./projet.sh
              -mandriva 2006.

              there you go, thanks for responding ^^
              0
              1. Hello everyone

                I also have a small problem with the access rights to my .bat: And this even though I gave it all the rights:
                -rwxrwxrwx 1 root root 113 Feb 4 11:19 projet.bat*

                However, when I run the .bat it shows me a permission error :/
                bash: ./projet.bat: /lib/modules/2.6.12-12mdk/comedi/drivers: bad interpreter: Permission denied

                Does anyone have a suggestion to share with me?

                Thank you all. :D
                0
                1. hello
                  to be clear: what do you do to run the bat, what machine, what distribution...
                  0
              2. Yes, I know, but Linux is not installed on my machine ^^

                I am just emulating it to quickly switch from WinXP to Linux, so there’s not too much risk on that side.
                0
                1. Hi
                  since you're a beginner, you shouldn't run batch processes as root, you could get into serious trouble:
                  for example, a
                  rm -r / home/moi/mesfichier
                  would destroy your entire Linux because a space was inserted between / and home
                  whereas as a normal user it wouldn't work.
                  0
                  1. no, he doesn't add it, he simply leaves:

                    -rw-r--r-- 1 root root 62 Oct 16 17:57 test.bat

                    and he doesn't add an "x" after the "rw"

                    -rwxr--r-- 1 root root 62 Oct 16 17:57 test.bat

                    Edit:

                    There, I managed to set the permissions for myself, using "chmod" with the octal value
                    #chmod 760 test.bat
                    -1
                    1. No, I clearly saw that I wasn't allowed to execute the test.bat file
                      but chmod +x doesn't change the access rights and that really is a problem :s

                      yet I am indeed in SuperUser (root) and I can't change the file access rights.

                      could it be because I'm using VirtualBox to emulate Linux 2.6?
                      0
                      1. Is he making a mistake?
                        0
                    2. Console :

                      # id
                      uid=0(root) gid=0(root) groupes=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy)
                      # ls -l
                      total 5
                      drwx---r-x 2 root root 40 Oct 16 18:08 Bureau/
                      -rw-r--r-- 1 root root 323 2 mai 2005 Set\ adresse\ IP
                      drwxr-xr-x 2 root root 182 6 mars 2007 scripts_exemples/
                      -rw-r--r-- 1 root root 62 Oct 16 17:57 test.bat
                      0

                      1.  # id uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy) # ls -i 3327 Bureau/ 3328 Définir\ l'adresse\ IP 3329 scripts_exemples/ 6904 test.bat 
                        0
                        1. It was indeed that! :s just simple basic mistakes.

                          However, a new error message:
                          -bash: ./test.bat: Permission denied
                          ??? Yet I am indeed under root ???
                          1
                          1. steps,

                            id

                            and,

                            ls -l
                            0
                        2. Apparemment, j'ai un problème avec le "shebang" ! car il me met comme message d'erreur :
                          -bash: ./test.bat: bin/sh: bad interpreter: No such file or directory
                          Pourtant, j'ai bien mis en en-tête de fichier :
                          #!bin/sh -x
                          2
                          1. Here are the steps you can follow to execute your program after making the file executable: ```html
                            Pour exécuter votre programme, vous devez utiliser la commande suivante dans votre console :
                            ./test.bat

                            Assurez-vous que vous êtes dans le bon répertoire où se trouve le fichier 'test.bat'. Si ce n'est pas le cas, naviguez jusqu'au répertoire approprié avec la commande
                            cd chemin/vers/le/répertoire

                            où 'chemin/vers/le/répertoire' est le chemin d'accès à l'emplacement de votre fichier. Ensuite, vous pouvez exécuter le programme comme indiqué.
                            ```
                            0
                            • 1
                            • 2