user2151887
user2151887

Reputation: 469

Pass string to shell script when run as command

I'm trying to write a shell script that builds an iso image from an .asm file with several utilities. When you run the script from the command line it first asks the user where the file is and where the iso file should be. I want the script accept arguments the user passed as part of the command: ./mkiso foo.iso bar.asm? The two arguments would correspond to two variables, input and output. How do I do this? EDIT: I'm using Linux and my script is a bash script.

Upvotes: 0

Views: 4108

Answers (1)

peterm
peterm

Reputation: 92785

mkiso:

#!/bin/bash
input=$1
output=$2
echo "input: $input, output: $output"

Run it with parameters

./mkiso aa.iso bb.asm

Output

input: aa.iso, output: bb.asm

Upvotes: 1

Related Questions