-2

I tried searching for this question but I couldn't find a thread specifically like this one. I am trying to do a practice script where you enter in a source and a destination and the program copies the files for you.

./testscript
"name of file to copy?"       file1
"to be copied to?"            file2
"file1 has been copied to file2"

So far I have this:

#!bin/bash
echo -e 'Enter file name of file you wish to copy'
read $FILE1
echo -e 'Enter the file you wish to copy to'
read $FILE2
if cp $FILE1 $FILE2
    then echo -e 'Copy was successful'
else echo -e 'Copy was unsuccessful'
fi

The program error is saying bad interpreter. I don't really understand, it looks okay from my end.

ajp15243
  • 7,704
  • 1
  • 32
  • 38
  • such a stupid mistake, thank you. I might have to work on the script since it's finding a problem with my code. "Missing File Operand" Thanks everyone for the help. – user3002042 Nov 19 '13 at 17:55
  • `read FILE1` and `read FILE2` -- the argument to `read` is the *name* of a parameter, not its value. As a result, `FILE1` and `FILE2` are never set for the `cp` command. – chepner Nov 19 '13 at 18:17

2 Answers2

0

The path you supplied as interpreter is not absolute (missing '/'). I suggest changing #!bin/bash to #!/usr/bin/env bash . See The difference between "#! /usr/bin/env bash" and "#! /usr/bin/bash"? for details.

Community
  • 1
  • 1
0

You have provided incorrect path to the interpreter. You are probably missing a forward slash in the beginning.

The shebang statement should say: #!/bin/bash (or whatever the correct path is)

gat
  • 2,872
  • 2
  • 18
  • 21