in reply to modifying script to ask for file name as input

Is it possible to modify this script to ask for input ...
Yes

But I think the better question is:

Is it possible to rewrite this script to simplify my life?
The answer to which is also Yes.

Here's your problem, as I see it:

  1. You have an input file whose name changes every time.
  2. You want to extract some columns from it.
  3. You need to reformat the data so your other software can process it.
So far, you're using awk and sed and the shell to do it, but your suspicions are correct: you can do it all in one Perl program. Here's one possibility:
open GRAPHIN, '>', 'data-in' or die "Can't open data-in: $!\n"; open GRAPHOUT, '>', data-out' or die "Can't open data-out: $!\n"; while (<>) # You can pass the input file name on the command line { my @f = split /\s/; # Like awk: split at white space print GRAPHIN $f[0], ' ', $f[3], "\n"; print GRAPHOUT $f[0], ' ', $f[4], "\n"; } close GRAPHIN; # Could live without these close GRAPHOUT; system './graph'; # Execute your graph program
And you're ready to go. Note that awk counts fields starting at 1, and Perl arrays start from 0.

This is not tested code, it's a guess at what you're trying to do. Unfortunately, my ESP is a little rusty, so I may have misread what you're trying to do. In any case, HTH.