*.bat file under Linux
Solved
kaham
Posted messages
174
Registration date
Status
Member
Last intervention
-
dindoun Posted messages 1047 Status Member -
dindoun Posted messages 1047 Status Member -
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.
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
- 2
Next
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 directoryPourtant, j'ai bien mis en en-tête de fichier :
#!bin/sh -x
Hello,
On GNU/Linux, it's very simple, you open a text editor, type your script (with a shebang at the top) and save it as a *.something file (but that's optional, you can save it as ".whatever" or even without an extension), make it executable (chmod +x the_file) and you're good to go ;-))
--
$ man woman
There is no manual page for woman.
On GNU/Linux, it's very simple, you open a text editor, type your script (with a shebang at the top) and save it as a *.something file (but that's optional, you can save it as ".whatever" or even without an extension), make it executable (chmod +x the_file) and you're good to go ;-))
--
$ man woman
There is no manual page for woman.
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 :
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
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é.
```
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é.
```
# 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
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
# 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
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.
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.
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.
I am just emulating it to quickly switch from WinXP to Linux, so there’s not too much risk on that side.
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
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
At the same time, the easiest thing would be for you to send us your script directly, we could correct it more easily!
- 1
- 2
Next