.bat to .sh converting for SQL*Loader Start on UNIX PC

為{幸葍}努か 提交于 2019-12-25 02:15:06

问题


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:

  1. 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 being sqlldr

  2. 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.

  3. 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 used sqlldr. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!