我有一个如下的脚本。我的目标是写入以当前日期和时间终止的日志文件作为文件名和假脱机到文件:
spool $logfile
当我执行脚本时,spool exec_proc_daily_2o.log
会出错。没有创建日志。但是当我使用像$logfile
这样的东西时它会起作用。为什么变量 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
let incrementAction = UIMutableUserNotificationAction()
incrementAction.identifier = "First"
incrementAction.title = "First"
incrementAction.activationMode = UIUserNotificationActivationMode.foreground
incrementAction.isAuthenticationRequired = true
incrementAction.isDestructive = true
let decrementAction = UIMutableUserNotificationAction()
decrementAction.identifier = "second"
decrementAction.title = "second"
decrementAction.activationMode = UIUserNotificationActivationMode.foreground
decrementAction.isAuthenticationRequired = true
decrementAction.isDestructive = false
// Category
let counterCategory = UIMutableUserNotificationCategory()
counterCategory.identifier = "BOOKING_CATEGORY"
// A. Set actions for the default context
counterCategory.setActions([incrementAction, decrementAction],
for: UIUserNotificationActionContext.default)
// B. Set actions for the minimal context //No more than 2
counterCategory.setActions([incrementAction, decrementAction],
for: UIUserNotificationActionContext.minimal)
// iOS 9 support
else if #available(iOS 9, *) {
UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: NSSet(object: counterCategory) as? Set<UIUserNotificationCategory>))
UIApplication.shared.registerForRemoteNotifications()
}
}
不能替换。
答案 0 :(得分:2)
经过大量挖掘后,我找到了问题的解决方案。在sqlplus / "as sysdba" <<EOF
行,我传递了像sqlplus / as sysdba <<EOF >$logfile
这样的变量。所以完整的代码应该是:
#!/bin/bash
year=`date +%Y`
month=`date +%m`
day=`date +%d`
prefixe=$month$day$year
logfile="/home/oracle/logs/exec_proc_daily_20_"$prefixe.log
sqlplus / "as sysdba" <<EOF >$logfile
spool on
spool $logfile
execute Proc_RFC_MAJ_MV_ITIN;
execute Proc_RFC_MAJ_MV_REFGEO;
commit;
quit
EOF
答案 1 :(得分:0)
[用工作示例编辑]将变量传递给sqlplus:
demo.sh
export myvar1="hello"
export myvar2=123
sqlplus "/ as sysdba" @demo.sql $myvar1 $myvar2
echo "---shell is complete---"
demo.sql
select 'first variable is &1 and second is &2'
from dual;
exit
答案 2 :(得分:0)
@Beege答案在linux env中有效。我做了很少的更改,因为我不希望在任何地方都在sql脚本中引用&1和&2。
myvar1="hello"
myvar2=123
sqlplus lpatel/Ied~ae6ieGhi@nheronB2 @oracle_variabling_passing.sql $myvar1 $myvar2
echo "---shell is complete---"
oracle_variabling_passing.sql:
define first_var=&1
define second_var=&2
select 'first variable is &&first_var and second is &&second_var'
from dual;
exit
答案 3 :(得分:0)
@Beege答案在Linux环境中有效。我所做的更改很少,因为我不想在所有地方都在SQL脚本中引用&1和&2。
myvar1="hello"
myvar2=123
sqlplus username/password@SID @oracle_variabling_passing.sql $myvar1 $myvar2
echo "---shell is complete---"
oracle_variabling_passing.sql:
define first_var=&1
define second_var=&2
select 'first variable is &&first_var and second is &&second_var'
from dual;
exit