Reputation: 3
I am learning Perl and Shell scripting and of the challenges I was given is to write a shell script that takes a csv file as an argument and then have that shell script run my perl script (test.pl). I can't seem to get the proper syntax down and I have terminate every time because it hangs up my terminal.
For example shell script is test.sh
#/bin/bash
./test.pl $i`
on my terminal I write type out
test.sh testfile.csv
Ultimately I want the test file to be read by my perl script so it can run.
Upvotes: 0
Views: 174
Reputation: 3079
I think your error comes from the $i`
part.
First the trailing backquote is probably a typo and should raise a syntax error. Second, the i
variable is not defined, so $i
resolve to an empty string. As it is not quoted, shell will omit it and call test.pl
without any arguments... Thus your terminal is probably hanging because your perl script is waiting for input.
As @fra suggested, you should use $1
instead of $i
, hence passing the first argument passed to your bash script, to your perl script.
Depending on your perl script (shebang, execution write) you may or may not call the perl executable manually.
Upvotes: 1