views:

1714

answers:

5

I'm running Oracle 11g on Linux and I'm trying to run a script which will create my database. This script runs fine on windows, but when I test it on Linux, I get the following error:

SP2-0556: Invalid File Name

The problem may be that the path to the file name has a space in it. I'm going to simplify the problem down to one of the many commands I run in the file to make it simple. The sample command I'm trying to run looks like this:

sqlplus [uname]/[pw] @'../database/My Schema/create_sequence.sql'

the create_sequence.sql file has two simple create sequence commands that run fine by themselves. I strongly suspect it is due to the white space because when I change the directory name from My Schema to MySchema and alter the above sqlplus command accordingly, the script runs fine.

Like I said, this script works in windows with the spaces, but not in Linux. I suspect spaces may not be supported, but I was wondering if anyone knew any different or it there is a work-around?

side note: running a command like:

more ../database/My\ Schema/create_sequence.sql

or

more "../database/My Schema/create_sequence.sql"

prints the contents of the file to the console as you would expect. So, I think this is sqlplus (and linux) specific.

A: 

have you tried escaping the white space?

Try:

sqlplus [uname]/[pw] @'../database/My\ Schema/create_sequence.sql'
northpole
I have tried that (with and without the enclosing quotes, single and double), and I get the same error "SP2-0556: Invalid File Name"
Stephen
have you tried doing the full path name rather than ../database/.. ?
northpole
when I use the full path name I get the same error, whether the space is escaped or the whole path/filename is enclosed in quotes.
Stephen
this could be a long shot, but what about file permissions on create_sequence.sql?
northpole
the user I am running as owns the file. Plus, when I change the directory name from My Schema to MySchema, the script runs. I know the easy solution is to rename all the dirs to not have spaces in them, but I'm looking for a more flexible solution/
Stephen
I completely understand that's why I didn't suggest just changing the dir name. Well I am out of ideas, sorry I can't be of more help.
northpole
A: 

If you're working with this under linux you can escape the space with a '\' character like such:

sqlplus [uname]/[pw] @../database/My\ Schema/create_sequence.sql
Mark Roddy
I have tried that (with and without the enclosing quotes, single and double), and I get the same error "SP2-0556: Invalid File Name"
Stephen
side note: running a command like: more ../database/My\ Schema/create_sequence.sql or more "../database/My Schema/create_sequence.sql" prints the contents of the file to the console as you would expect. So, I think this is sqlplus specific.
Stephen
+1  A: 

Well, if this is a Linux issue (see my comment on your question - it works fine on Solaris), you may have to try something along the lines of:

sqlplus [uname]/[pw] < '../database/My Schema/create_sequence.sql'

You run into problems if you're trying to pass parameters to your sql script, however...

EDIT: There seems to be a Metalink issue raised for a very similar problem: "Bug 7150873 SQL scripts with filename containing spaces results in SP2-0556". It is listed as affecting 10.2.0.4 and 11.1. It is supposedly fixed in 10.2.0.5 and 11.2, neither which are available yet. It does say it's a generic issue affecting most/all platforms, so I don't know if this is your problem or not.

The specific text of the issue: "The SQLPLUS START command fails to execute SQL scripts which have a space in the filename."

Just for grins, what happens if you do the following:

sqlplus [uname]/[pw]
start '../database/My Schema/create_sequence.sql'

EDIT2: I don't know if modifying your scripts wholesale is feasible or not, but a workaround might be:

cp '../database/My Schema/file2run.sql' ./temp.sql
sqlplus [uname]/[pw] @temp.sql
rm ./temp.sql

You would need to wrap each sqlplus call this way. Another option would be to create a shell script, say with a name of mysqlplus.sh:

#!/bin/sh
cp $2 ./temp$$
sqlplus $1 @$2
rm ./temp$$

Then modify your build scripts thus:

mysqlplus.sh [uname]/[pw] '../database/My Schema/create_sequence.sql'
DCookie
so close... It does work, but I do need to be able to use the @ syntax because of how we are using these files to deploy the database.
Stephen
I appreciate the extra info about the bug as I don't have access to metalink. sounds like that is the issue.
Stephen
If I had the rep points I would +1 this :-) thanks for the effort!
Stephen
+1  A: 

According to this thread on the OTN site, SP2-0556 can be caused by invalid white space characters in the file that is being executed. Likely the Linux version of SQL-Plus doesn't know how to deal with Windows newline character(s). Try deleting the existing file and recreating it with your desired commands (you said there are only 2 DDL commands so it should be easy).

Mark Roddy
+1, bet that's it.
DCookie
same error. Remember, this same exact command works if I renamed the directory from "My Schema" to MySchema and modify the command so it looks like this: sqlplus [uname]/[pw] @'../database/MySchema/create_sequence.sql' So I don't think it's a problem with the file or the commands in it.
Stephen
Yup, forgot that detail. The answer is still a good reminder that windows and *nix deal with newlines differently.
DCookie
+1  A: 

I connected to one of my Linux boxes and was pretty easily able to reproduce this issue. There doesn't seem to be any way that I can find to execute the file with the '@' option from the command line so I think you're left with the following options for work arounds:

  1. Rename the My Schema directory to no longer have a space in it (as well as updating all other scripts that reference it
  2. Execute the file from the directory in which it resides (I confirmed that this works, see below)
  3. Send the file into sqlplus via stdin (see below)

You should also file a report with Oracle support as there may be a simple fix that they can provide.

Example Commands:

From Directory

cd ../database/My\ Schema
sqlplus [uname]/[pw] @create_sequence.sql

Via stdin

sqlplus [uname]/[pw] < ../database/My\ Schema/create_sequence.sql
Mark Roddy
I have come to this same conclusion. Seems like it is a bug which may be fixed in 11.2 (HT: DCookie below), but I can't wait for that. Plus, it's probably easier to change my directory structure than to require 11.2 over 11.1 due to some obscure bug fix...
Stephen