java - How to fetch specific word from long string with particular keyword -
i have string below:-
this string output of command find services entry in config file , print out. here b c etc services , respective services entry or config parameters.
map(s): service.cfg os_serv 0 0 0 50 50 1 "d:\workdir\upg_81\bin\olaunch" -f "d:\workdir\upg_81\bin\osserv" gui svr 0 0 1 99 99 2 "d:\workdir\upg_81\bin\olaunch" -f "d:\workdir\upg_81\bin\omf" -a netcap 0 1 1 1 1 60 "d:\workdir\up g_81\bin\netcap" netprobe 0 0 0 99 99 1 "d:\workdir\upg_81\bin\netprobe" lamserv 1 1 1 1 1 10 "d:\workdir\upg_81\ bin\lamserv" mserv 1 1 1 1 1 10 "d:\workdir\upg_81\bin\mserv" uidserv 1 1 1 1 1 10 "d:\workdir\upg_81\bin\uidser v" rserv 0 1 1 1 1 10 "d:\workdir\upg_81\bin\rserv" nlsserv 1 1 1 1 1 10 "d:\workdir\upg_81\bin\nlsserv" om fsvr 1 1 25 25 25 60 "d:\workdir\upg_81\bin\objserv" -c 250 searchserv 0 0 0 12 12 10 "d:\workdir\upg_81\bin\search" - s searchserv notifserv 0 0 0 1 1 10 "d:\workdir\upg_81\bin\notif" -c 250 notifservbroker 0 0 0 1 1 10 "d:\workdir \upg_81\bin\eventqb" -s notifservbroker mloader 1 1 1 1 1 10 "d:\workdir\upg_81\bin\mloader" postserv 0 1 1 3 3 1 0 "d:\workdir\upg_81\bin\post" -h advancerserv 0 0 0 3 3 10 "d:\workdir\upg_81\bin\advancer" -c 250 advancerserv broker 0 0 0 1 1 10 "d:\workdir\upg_81\bin\eventqb" -s advancerservbroker scheduleserv 0 1 1 1 1 10 "d:\workdir\upg_81 \bin\schedule" registry 0 1 1 1 1 10 "d:\workdir\upg_81\bin\rgyserv" repserv 0 0 0 0 0 10 "d:\workdir\upg_81\bin\ replic8r" repservbroker 0 0 0 1 1 10 "d:\workdir\upg_81\bin\eventqb" -s repservbroker cacheserv 0 1 1 1 1 10 "d:\ workdir\upg_81\bin\cachesche" -c 250 eventlogger 0 0 1 1 1 10 "d:\workdir\upg_81\bin\eventlogger" -s expireserv 0 0 1 1 1 10 "d:\workdir\upg_81\bin\expire" parteolserv 0 0 1 1 1 10 "d:\workdir\upg_81\bin\parteol" -r 90 msqlpdm m81dm 0 0 25 25 25 2 "d:\workdir\upg_81\bin\msqlora" -sn d:\workdir\upg_81\config\pdmm81dm.pwf -c 5000 mgrsvr 0 0 1 1 1 10 "d:\workdir\upg_81\bin\mgrora"
i want fetch d:\workdir\upg_81\config\pdmm81dm.pwf
of service msqlpdmm81dm
string using java , password file cloud -s , -n or -sn option. please suggest better way.
it working fine code,
cfgtest utility parses configuration file , returns specific entry config file.
process p = _executeprocess("cfgtest","-m","service.cfg"); bufferedreader br = new bufferedreader( new inputstreamreader( p.getinputstream() ) ); string s = br.readline(); while ( s != null ) { if ( s.matches( "^\\s*msql.*$" ) ) { stringtokenizer st = new stringtokenizer( s, " " ); while ( st.hasmoretokens() ) { if ( st.nexttoken().equals( "-sn" ) ) { pwf = st.nexttoken(); } } } s = br.readline(); } br.close();
but change approach , try function returns cfgtest command output single string.
string cmd = "cfgtest -m service.cfg"; int dstat = shell._execcommand(cmd); string s = null; s = shell._getcommandoutput(); system.out.println(s);
Comments
Post a Comment