This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 请高人指导一下,shell scriptscript_1.sh:
#!/bin/ksh
isql -S server_name -U user_is -P pwd -o Result_file -i script_2.sql $1
script_2.sql:
set nocount on
select File_Name
from a
where File_Name in File_Name_From_FTP
script_2.sql里的File_Name_From_FTP是个变量,在运行时从外部传进来,请问我这script_2该怎么写?
-zxcvb(朝天椒);
2005-5-5
{290}
(#2279500@0)
-
up!
-zxcvb(朝天椒);
2005-5-5
(#2279521@0)
-
script_2.sql:
set nocount on
select File_Name
from a
where File_Name in File_Name_From_FTP
-ddbb(bbdd);
2005-5-5
(#2279525@0)
-
改了一下script_2.sql:
set nocount on
declare @File_Name_From_FTP nvarchar(255)
select @File_Name_From_FTP='xxxxx'
select File_Name
from a
where File_Name in @File_Name_From_FTP
script是执行了,可是我是用select @File_Name_From_FTP='xxxxx'给@File_Name_From_FTP赋的值,怎么从外部传数据进来呢?
谢谢!
-zxcvb(朝天椒);
2005-5-5
{301}
(#2279560@0)
-
let me try, how about this:make sql2 as template, and use shell script to replace the FILE_NAME with the env var value, something like this:
sed -e "s/File_Name_From_FTP/$THE_ENV_VAR/g" < script_2.template > script_2.sql
then execute the script_2.sql
-xordos(donothing);
2005-5-6
{231}
(#2280605@0)
-
多谢多谢,好办法!
-zxcvb(朝天椒);
2005-5-6
(#2281165@0)
-
I don't know what environment you are using:DB? for input from shell script, you can use command 'man -a read' to check the 'read' usage in shell.
-647i(六不一没有);
2005-5-6
(#2280532@0)
-
谢谢
-zxcvb(朝天椒);
2005-5-6
(#2281169@0)
-
1. export your var before run the two script using "export File_Name_From_FTP"2. direct call the var name in your script. If you want to generate a string first, then run it. eval in ksh will help you
-bugfree(BugFree);
2005-5-14
{122}
(#2294628@0)
-
看了你的shell好象你用的是sybase数据库把,你要加go 在每个sql后面,否则不执行,这是sybase的规定
-zjx_cool(zjx);
2005-5-17
(#2300682@0)
-
专业的做法是在Unix Shell Script里用HERE DOCUMENT,如此则Sybase T-SQL 可引用UNIX Shell变量.
-oraclefun(准备跳槽);
2005-5-17
(#2301103@0)