DATA Step, Macro, Functions and more

run shell script error

Reply
Regular Contributor
Posts: 208

run shell script error

Hello everyone,

 

I have a shell script in unix whose name is : batching.csh

Here is the code inside this file:

 

#!/bin/ksh
cd /Program_Directory/
sas prog_1.sas &

 

My problem is when I run this script it told me "Command not found"

 

             xnzspap23x-tcsh-23$ batching.csh
             batching.csh: Command not found.

This is my first time create a shell script in unix, please help me!

 

Thank you!

Super User
Posts: 17,868

Re: run shell script error

First figure out the command line that you need directly in Unix. 

Then you incorporate those into a sh file that you call from Unix and test

Then you test it in SAS. 

 

Which step are you on now?

Regular Contributor
Posts: 208

Re: run shell script error

I found the problem is I use notepad to edit the .csh file. when I use vi to create this file it works.
but vi is very not convenient to edit like notepad. any suggestion?
Super User
Posts: 17,868

Re: run shell script error

When you save it make sure it gets saved with the .sh extension and doesn't get named filename.sh.txt or something of the sort.

Super User
Posts: 6,946

Re: run shell script error

I would not use something as crude as Windows Notepad for programming work (which inlcudes shell scripting).

Actually, I still use vi for scripts

- is available on ALL UNIX platforms with the same syntax

- works even over a simple telnet connection, as it does not need any function keys/mousing around/etc

- can edit files of arbitrary size, although it might change to line mode with sufficiently large files.

 

If you are working on UNIX from Windows, I recommend using notepad++, as it can write text files in UNIX mode (LF instead of CRLF), provides a hex display mode, and lots of other features that are helpful when writing any type of code.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 6,946

Re: run shell script error

If the directory where your script is stored is not in the PATH environment variable, you need to supply the whole path for the command. Or at least ./ for the current directory.
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 5 replies
  • 199 views
  • 3 likes
  • 3 in conversation