试图确保在when条件下存在确切的字符串,但是现在尝试使函数在简单的剧本中运行,但似乎无法使其正常工作。还尝试过转义字符
我尝试了不同的变体,并尝试切换到“而不是”,反之亦然
my.conf
JAVA_HOME="/opt/java/hotspot/64_bit/jdk1.8.0_201/"
JAVA_HOME=/opt/java/hotspot/64_bit/jdk1.8.0_201/
JAVA_HOME=/opt/java/hotspot/64_bit/jdk1.8.0_202/
JAVA_HOME="/opt/java/hotspot/64_bit/jdk1.8.0_202/"
SUN_JAVA_HOME=/opt/java/hotspot/64_bit/jdk1.8.0_201/
SUN_JAVA_HOME="/opt/java/hotspot/64_bit/jdk1.8.0_201/"
BAE_JAVA_HOME=/opt/java/hotspot/64_bit/jdk1.8.0_201/
BAE_JAVA_HOME=/opt/java/hotspot/64_bit/jdk1.8.0_202/
BAE_JAVA_HOME="/opt/java/hotspot/64_bit/jdk1.8.0_201/"
BAE_JAVA_HOME="/opt/java/hotspot/64_bit/jdk1.8.0_202/"
剧本
---
- hosts: localhost
tasks:
- name: read the passwd file
shell: cat /tmp/my.conf
changed_when: False
register: user_accts
- name: set regex pattern
set_fact:
regex_pattern: ".*^JAVA_HOME=\"/opt/java/hotspot/64_bit/jdk1.8.0_201/\"$"
- name: a task that only happens if the user exists
when: user_accts.stdout |match('{{regex_pattern}}')
debug: msg="user hillsy exists"
我想确保它找到了这个JAVA_HOME =“ / opt / java / hotspot / 64_bit / jdk1.8.0_201 /” 如果我将此行更改为 JAVA_HOME =“ / opt / java / hotspot / 64_bit / jdk1.8.0_209 /” 找不到它
答案 0 :(得分:0)
我想获取确切的字符串,所以在上面的示例中我没有得到其他字符串
如果您要查找确切的字符串,则不需要正则表达式
create or replace package vendordb.p_enld0055_va is
PROCEDURE sp_group_id_update(p_batch_id NUMBER,
p_file_name VARCHAR2,
p_group_id VARCHAR2);
end p_enld0055_va;
/
create or replace package body vendordb.p_enld0055_va is
PROCEDURE sp_group_id_update(p_batch_id NUMBER,
p_file_name VARCHAR2,
p_group_id VARCHAR2) is
v_batch_id VARCHAR2(100) := p_batch_id;
v_file_name VARCHAR2(100) := p_file_name;
v_group_id VARCHAR2(100) := p_group_id;
type t_TBL_row_ID IS TABLE OF ROWID;
v_row_ID t_TBL_row_ID;
cursor CUR_PPL is
select
h.rowid
from VENDORDB.CLAIM_PROF_HDR h
where batch_id = v_batch_id ;
Begin
open CUR_PPL;
loop
fetch CUR_PPL
bulk collect into v_row_ID
limit 1000
;
exit when v_row_ID.count()=0;
forall i in 1 .. v_row_ID.count()
UPDATE VENDORDB.CLAIM_PROF_HDR h
SET group_id = CASE
WHEN EXISTS (select file_name from
nemis.file_control where batch_id = v_batch_id and file_name like
v_file_name) THEN v_group_id
ELSE NULL
END
where h.rowid = v_row_ID(i);
commit;
end loop;
close CUR_PPL ;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('UNEXPECTED ERROR OCCURED');
ROLLBACK;
end;
end p_enld0055_va;
/