问题
I have a simple .bat file
@echo; set nls_lang=russian_cis.ru8pc866
@echo off
SET NLS_NUMERIC_CHARACTERS=. '
sqlldr.exe userid=PRB/0611@TSESTDB control=control_file.ctl LOG=fdb_log.log errors=100
cmd
and i need to convert to .sh file for running on the UNIX based pc. I began to read "BASH Programming - Introduction HOW-TO" (is it suitable for beginners?), but it is a episodical task and dead line comes.
Could anybody help me to convert file? Thanks a lot!!!
回答1:
rewriting your script.
#!/bin/bash
# @echo;
# set nls_lang=russian_cis.ru8pc866
export NLS_LANG=russian_cis.ru8pc866
# not needed @echo off
# SET NLS_NUMERIC_CHARACTERS=. '
export NLS_NUMERIC_CHARACTERS='.'
PATH="/path/to/sqlDir/install:${PATH}"
# sqlldr.exe userid=PRB/0611@TSESTDB control=control_file.ctl LOG=fdb_log.log errors=100
sqlldr userid=PRB/0611@TSESTDB control=control_file.ctl LOG=fdb_log.log errors=100
# ? cmd
I've left your code in, but commented out (using the shell comment char '#'). The uncommented lines are the 'translation' of .bat syntax into Linux/Unix bash/shell syntax.
There some things above that you may need to fix:
You'll have to include the correct value in the resetting of PATH, note that the value there is strictly to illustrate the issue.
export
is used so that variables set in the current shell (the shell script) are visible to child processes that run from the shell script, in this case the important one beingsqlldr
I'm not sure what values you really need assigned to
NLS_NUMERIC_CHARACTERS
. Note that by quoting with the single-quote char'
available to the shell, you should get exactly the value used that you intended. If '*' or other reg-exp chars are used, this may cause problems.You may find that
sqlldr.exe
has a different name altogether. The linux/unix convention for executable commands does not require the.exe
extension, so I have usedsqlldr
. Just use the full name of the program you find in the installed directory.
The line with #!/bin/bash
needs to be the first line in the file, with no leading spaces.
You'll also need to inform your OS that the script is intended to be executable. From a bash cmd line, IN the directory that contains this script, do
chmod 755 mySQLLDR_runningScript
Finally, not sure why you have cmd
at the end of your .bat file, to open a new window? You'll need to experiment on your system to find the correct cmd to do that. Maybe xterm
.
I hope this helps.
来源:https://stackoverflow.com/questions/10317521/bat-to-sh-converting-for-sqlloader-start-on-unix-pc