Difference between revisions of "CSC231 Bash Tutorial 6"
(Created page with "--~~~~ ---- =Script File= <br /> Let's create a simple batch file that will allow you to automatically '''assemble''', '''link''', and '''run''' an assembly program. Further...") |
(→Script File) |
||
Line 12: | Line 12: | ||
./''progName | ./''progName | ||
− | Let's create a script file called ''nald'' (for '''na'''sm '''ld''') that will run these 3 commands automatically | + | Let's create a script file called ''nald'' (for '''na'''sm '''ld''') that will run these 3 commands automatically. For now, just copy the code without worrying too much about what happens. We'll explain what's going on later. |
* emacs a new file called '''nald''' | * emacs a new file called '''nald''' | ||
Line 27: | Line 27: | ||
</source> | </source> | ||
<br /> | <br /> | ||
+ | * Make sure that the #-sign is the first character on the first line of the script. | ||
+ | * Make the script executable: | ||
+ | |||
+ | chmod +x nald | ||
+ | |||
+ | :chmod is a command that changes the permissions of a file. "'''+x'''" means that everybody including you, everybody in the 231 class, and everybody who has an account on Aurora can execute your script. | ||
<br /> | <br /> | ||
<br /> | <br /> |
Revision as of 22:21, 21 March 2017
--D. Thiebaut (talk) 22:18, 21 March 2017 (EDT)
Script File
Let's create a simple batch file that will allow you to automatically assemble, link, and run an assembly program. Furthermore, we'll link it with the 231Lib library, just to be safe. If it doesn't use it, it should be fine.
The commands you normally use to go through this process are the following:
nasm -f elf progName.asm ld -melf_i386 progName.o 231Lib.o -o progName ./progName
Let's create a script file called nald (for nasm ld) that will run these 3 commands automatically. For now, just copy the code without worrying too much about what happens. We'll explain what's going on later.
- emacs a new file called nald
- Store the following lines in it:
#! /bin/bash nasm -f elf $1.asm nasm -f elf 231Lib.asm ld -melf_i386 $1.o 231Lib.o -o $1 ./$1
- Make sure that the #-sign is the first character on the first line of the script.
- Make the script executable:
chmod +x nald
- chmod is a command that changes the permissions of a file. "+x" means that everybody including you, everybody in the 231 class, and everybody who has an account on Aurora can execute your script.