ssh seawulfLast failed login: Tue Apr 7 13:50:18 EDT 2026 from 172.20.26.244 on ssh:notty
There were 3 failed login attempts since the last successful login.
Last login: Tue Apr 7 13:39:17 2026 from 172.20.24.214sallocsalloc: Granted job allocation 28320
salloc: Waiting for resource configuration
salloc: Nodes n005 are ready for jobpwd/home/brownsarahmlsbash-lesson.tar.gz SRR307024_1.fastq SRR307027_2.fastq
demo SRR307024_2.fastq SRR307028_1.fastq
dmel-all-r6.19.gtf SRR307025_1.fastq SRR307028_2.fastq
dmel_unique_protein_isoforms_fb_2016_01.tsv SRR307025_2.fastq SRR307029_1.fastq
gene_association.fb SRR307026_1.fastq SRR307029_2.fastq
SRR307023_1.fastq SRR307026_2.fastq SRR307030_1.fastq
SRR307023_2.fastq SRR307027_1.fastq SRR307030_2.fastqmkdir compileccd compilec/nano hello.clshello.ccat hello.c#include <stdio.h>
void main () {
printf("Hello world\n");
}gcc -E hello.c -o hello.ilshello.c hello.iwc -l hello.* 6 hello.c
842 hello.i
848 totalhead hello.i -n 5# 1 "hello.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2tail hello.iextern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
# 943 "/usr/include/stdio.h" 3 4
# 2 "hello.c" 2
void main () {
printf("Hello world\n");
}gcc -S hello.ilshello.c hello.i hello.swc -l hello.* 6 hello.c
842 hello.i
25 hello.s
873 totalcat hello.s .file "hello.c"
.section .rodata
.LC0:
.string "Hello world"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $.LC0, %edi
call puts
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44)"
.section .note.GNU-stack,"",@progbitsgcc -c hello.s -o hello.olshello.c hello.i hello.o hello.swc -l hello.* 6 hello.c
842 hello.i
5 hello.o
25 hello.s
878 totalcat hello.oELF>?@@
UH???]?Hello worldGCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44)zRx
K A?C
?? hello.cmainputs
???????? .symtab.strtab.shstrtab.rela.text.data.bss.rodata.comment.note.GNU-stack.rela.eh_frame @?0
&PP1P
90\.B?W?R@wc hello.o 5 17 1496 hello.owc -c hello.o1496 hello.ogcc -o hello hello.o -lmlshello hello.c hello.i hello.o hello.s./helloHello worldls -a. .. hello hello.c hello.i hello.o hello.sls -lhtotal 44K
-rwxr-xr-x. 1 brownsarahm spring2022-csc392 8.2K Apr 9 13:24 hello
-rw-r--r--. 1 brownsarahm spring2022-csc392 64 Apr 9 12:57 hello.c
-rw-r--r--. 1 brownsarahm spring2022-csc392 17K Apr 9 12:59 hello.i
-rw-r--r--. 1 brownsarahm spring2022-csc392 1.5K Apr 9 13:15 hello.o
-rw-r--r--. 1 brownsarahm spring2022-csc392 433 Apr 9 13:03 hello.sgcc -o demohello hello.o -lm./demohelloHello worldgcc -o demohello hello.c -lm./demohelloHello worldnano hello.ccat hello.c#include <stdio.h>
void main () {
printf("Hello world!\n");
}./demohelloHello worldgcc -o demohello hello.c -lm./demohelloHello world!nano main.ccat main.c/* Used to illustrate separate compilation.
Created: Joe Zachary, October 22, 1992
Modified:
*/
#include <stdio.h>
void main () {
int n;
printf("Please enter a small positive integer: ");
scanf("%d", &n);
printf("The sum of the first n integers is %d\n", sum(n));
printf("The product of the first n integers is %d\n", product(n));
}nano help.ccat helcat: hel: No such file or directorycat help.c/* Used to illustrate separate compilation
Created: Joe Zachary, October 22, 1992
Modified:
*/
/* Requires that "n" be positive. Returns the sum of the
first "n" integers. */
int sum (int n) {
int i;
int total = 0;
for (i = 1; i <= n; i++)
total += i;
return(total);
}
/* Requires that "n" be positive. Returns the product of the
first "n" integers. */
int product (int n) {
int i;
int total = 1;
for (i = 1; i <= n; i++)
total *= i;
return(total);
}gcc -Wall -g -c main.cmain.c:8:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
void main () {
^
main.c: In function ‘main’:
main.c:12:2: warning: implicit declaration of function ‘sum’ [-Wimplicit-function-declaration]
printf("The sum of the first n integers is %d\n", sum(n));
^
main.c:13:2: warning: implicit declaration of function ‘product’ [-Wimplicit-function-declaration]
printf("The product of the first n integers is %d\n", product(n));
^gcc -Wall -g -c help.clsdemohello hello hello.c hello.i hello.o hello.s help.c help.o main.c main.ogcc -o demo main.o help.o -lmlsdemo demohello hello hello.c hello.i hello.o hello.s help.c help.o main.c main.o./demoPlease enter a small positive integer: 8
The sum of the first n integers is 36
The product of the first n integers is 40320nano main.ccat main.c/* Used to illustrate separate compilation.
Created: Joe Zachary, October 22, 1992
Modified:
*/
#include <stdio.h>
void main () {
int n;
printf("Please enter a small positive integer: ");
scanf("%d", &n);
printf("The sum of the first n integers is: %d\n", sum(n));
printf("The product of the first n integers is: %d\n", product(n));
}./demoPlease enter a small positive integer: 6
The sum of the first n integers is 21
The product of the first n integers is 720gcc -Wall -g -c main.cmain.c:8:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
void main () {
^
main.c: In function ‘main’:
main.c:12:2: warning: implicit declaration of function ‘sum’ [-Wimplicit-function-declaration]
printf("The sum of the first n integers is: %d\n", sum(n));
^
main.c:13:2: warning: implicit declaration of function ‘product’ [-Wimplicit-function-declaration]
printf("The product of the first n integers is: %d\n", product(n));
^./demoPlease enter a small positive integer: 7
The sum of the first n integers is 28
The product of the first n integers is 5040gcc -o demo main.o help.o -lm./demoPlease enter a small positive integer: 7
The sum of the first n integers is: 28
The product of the first n integers is: 5040logoutbash: logout: not login shell: use `exit'exirbash: exir: command not foundexitexit
salloc: Relinquishing job allocation 28320
salloc: Job allocation 28320 has been revoked.logoutConnection to seawulf.uri.edu closed.
(base) ```
+++{"lesson_part": "main"}
```{code-cell} bash
:tags: ["skip-execution"]## Prepare for Next Class
```{include} ../_prepare/2026-04-14.mdBadges¶
Review the notes from today
Create some variations of the
hello.cwe made in class. Make hello2.c print twice with 2 print commands. Make hello5.c print 5 times with a for loop and hello7.c print 7 times with a for loop. Build them all on the command line and make sure they run correctly.Write a bash script, assembly.sh to compile each program to assembly and print the number of lines in each file.
Put the output of your script in hello_assembly_compare.md. Add to the file some notes on how they are similar or different based on your own reading of them.
Review the notes from today
On Seawulf, modfiy main.c from class to accept the integer as a command line argument instead of via input while running the program. See this tutorial for an example.
Write a bash script demo_test.sh that runs your compiled program for each integer from 10 to 30 (syntax for a range is
{start..end}so this would be{10..30})Write an sbatch script, batchrun.sh to run your script on a compute node and save the output to a file. The sbatch script should compile and link the program and then call the script. see the options
use scp to download your modified main, script files, and output to your local computer and include them in your kwl repo.
Create some variations of the
hello.cwe made in class. Make hello2.c print twice with 2 print commands. Make hello5.c print 5 times with a for loop and hello7.c print 7 times with a for loop. Build them all on the command line and make sure they run correctly.Write a bash script, assembly.sh to compile each program to assembly and print the number of lines in each file.
Put the output of your script in hello_assembly_compare.md. Add to the file some notes on how they are similar or different based on your own reading of them.