0
votes

I'm trying to use a vim script that issues commands to sas, When i try to run the script i receive an error

"Can't open file ..path.. /AppData/Local/Temp/ .. temp file .. "

this is the path and file name returned by :tempname()

After navigating to the appdata temp files directory, the temp file does not exist.

I've tried manually changing the backup directory with set backupdir=~\tmp (a directory I created) but that doesn't change the return value of :tempname() nor does the tempfile actually exist.

Two questions, 1. Is there a way to ensure vim is writing the file the script seems to need 2. can i rewrite the script to avoid needing a temp file? (just pass the path to the actual file to sas?)

the relevant part of the script is

    let returntxt = system("\"" .
    \ shellescape("C:\\Program\ Files\\SAS\\SASFoundation\\9.2\\sas.exe") .
    \ "\ -nosplash" . "\ -sysin" . "\ " .
    \ shellescape(expand("%:p")) .  "\"") 

" Shows the return messages from the SAS commandline (may be useful
" if no log produced)
:echo "*** SAS commandline: " . returntxt
1

1 Answers

2
votes

Option 'backupdir' contains a list of directories where backup files are generated, it has nothing to do with temporary directory (except that it depends on where it is located, opposite is not true). You should try using %TMP% or %TEMP% environment variable, either from vim using

let $TMP=expand('~/tmp')

or before vim is launched (don’t know how to do this on windows). Using let $TMP does work for me under wine, but only for existing temporary directories.

Note that your system() call is rather strange: shellescape() should already add all needed quotes so that surrounding "\"" are not required (if it does not you should properly configure 'shell*' options). You also don’t need to escape spaces: "\ " and " " are exactly the same strings.

About second question: you can try passing file contents as a second argument to system(), but if file may contain NULLs it is not going to work.