0

I have been using the Pause function that is in the thread:

What is the Linux equivalent to DOS pause?

I did a fresh install of CentOS 9 and tried to run the scripts that I built using the

# !/bin/bash

 source variables.sh

`function pause(){
    read -p "$*"
}`

I get this error message now:

 : No such file or directoryariables.sh

'/pac-installv8: command substitution: line 18: syntax error near unexpected token `{
'/pac-installv8: command substitution: line 18: `function pause(){

I have run the yum update -q -y for the OS to see if that fixed the function but it did not. The source variables.sh file that I am including is giving a file not found error even though I can use that same variable.sh file in a test script from the same root folder and it runs just find

#!/bin/bash/

source variables.sh
echo "dbuser=$dbuser"

This works just find with no errors on the same server. I figure it has to be an OS issue but don't know where to begin to look. Thanks for any help.

Sherwin

Community
  • 1
  • 1
user1794918
  • 1,131
  • 2
  • 16
  • 34
  • Your script has carriage returns (note the leading quote in the errors). Run `dos2unix` on the script file. – glenn jackman Nov 12 '12 at 17:44
  • Glenn you hit it dead on the head. I did not think about that. I copied the files from a windows machine that I wrote them on to a Unix machine and forgot to convert them. THANKS!!! – user1794918 Nov 13 '12 at 00:32

1 Answers1

0

The error message is from your source command. Where did variables.sh come from? You probably need to use the full path name.

Your first line has an error, there should not be a space between the # and the !, it should be #!/bin/bash (optional space after the !).

The backticks are unnecessary around the function, and the syntax is either:

function pause { ... }

or

pause() { ... }

not both, although that should not generate an error.

cdarke
  • 42,728
  • 8
  • 80
  • 84