本文介绍了在Linux PC上从.bat转换为SQL * Loader的.sh的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的.bat文件

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

,我需要转换为.sh文件才能在基于UNIX的pc上运行.我开始阅读" BASH编程-简介如何"(它适合初学者吗?),但这是一个荒诞的任务,死线来了.

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!!!

推荐答案

重写脚本.

  #!/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

我保留了您的代码,但是将其注释掉了(使用shell注释char'#').未注释的行是将.bat语法翻译"为Linux/Unix bash/shell语法.

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. 您必须在重置PATH中包含正确的值,请注意,此处的值严格用于说明问题.export用于使变量在当前shell中设置(Shell脚本)对从Shell运行的子进程可见脚本,在这种情况下,重要的是sqlldr

  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 (theshell script) are visible to child processes that run from the shellscript, in this case the important one being sqlldr

我不确定您真正需要分配给哪些值 NLS_NUMERIC_CHARACTERS.请注意,用单引号引起来 char '可用于外壳程序,您应该确切获得该值 使用了您的预期.如果使用"*"或其他正则表达式字符,则此 可能会引起问题.

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.

您可能会发现sqlldr.exe的名称完全不同.这 可执行命令的linux/unix约定不需要 .exe扩展名,所以我用过sqlldr.只需使用的全名 您在已安装目录中找到的程序.

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.

带有#!/bin/bash的行必须是文件中的第一行,且没有前导空格.

The line with #!/bin/bash needs to be the first line in the file, with no leading spaces.

您还需要通知操作系统该脚本旨在执行.从bash cmd行中,在包含此脚本的目录中,执行

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

最后,不确定为什么在.bat文件末尾有cmd来打开新窗口吗?您需要在系统上进行实验,以找到正确的cmd来执行此操作.也许xterm.

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.

我希望这会有所帮助.

这篇关于在Linux PC上从.bat转换为SQL * Loader的.sh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 19:51