hi i am trying to automate a Firewall config and i have a bellow line in a congig .. "user1" "user2" "user3" "User4" .... "user100" now i need to delete string "user2" but dont understand what would be the best way i was thinking to spilit this into array then delete the value then create again with same syntax from array can any one please help me .
on 2012-08-13 20:18
on 2012-08-13 22:00
On Mon, Aug 13, 2012 at 1:18 PM, Fosiul Alam <lists@ruby-forum.com> wrote: > hi i am trying to automate a Firewall config and i have a bellow line in > a congig .. Someone just asked here about deleting lines from a file; this would be pretty much the same (i.e. you'd read in the file, make your deletions in the in-memory copy, and then write it out to disk). > can any one please help me . I guess that depends on how the data's laid out. If it's really "user2" in quotation marks, I would do a gsub on /"user2"/ and replace it with nothing (unless you want to delete whitespace on one side or another, in which case you'd add that to your regular expression). But it might make sense to split it, delete instances of the string, and then rejoin it, before writing back to disk.
on 2012-08-14 10:13
Hi thanks
and sorry for late reply.
when i connect to fw by ssh and type the command
"show user group fosiultest "
I get bellow output
config user group
edit "fosiultest"
set member "user1 “ "user2 “ "user3 “ "user4 “ "user5 “
"user6 “ "user7 “ "user8 “ "user9 “ "user10 “
next
end
so now i need to grab this line
set member "user1 “ "user2 “ "user3 “ "user4 “ "user5 “ "user6 “
"user7 “ "user8 “ "user9 “ "user10 “
and have some how have to delete user3 .
but dont understand how to do that ..
on 2012-08-14 11:07
HI Sorry
the final file i got it like this
set member "user1" "user2" "user3" "user4" "user5" "user6"
"user7" "user9" "user10" "user11" "user12" "user13" " user14" " user15"
" user16" " user17" " user18" " user19" " user20"
From here I wil have to delete a user call user7
how i do that ?
on 2012-08-14 13:49
On Aug 14, 2012, at 2:07 AM, Fosiul Alam <lists@ruby-forum.com> wrote: > HI Sorry > the final file i got it like this > > set member "user1" "user2" "user3" "user4" "user5" "user6" > "user7" "user9" "user10" "user11" "user12" "user13" " user14" " user15" > " user16" " user17" " user18" " user19" " user20" > > From here I wil have to delete a user call user7 > > how i do that ? Can you please clarify? Are we doing your job or your homework?
on 2012-08-14 14:06
Look at the tokenizer. use the string to be removed as the divider like the comma in a csv. Then output the tokens as a single string. (all remove all instances of it).
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.