forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


combine multiple lines into one

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
bbelcher
Contributor
Contributor


Joined: 30 Jul 2002
Posts: 172

PostPosted: Fri Jan 09, 2004 1:50 pm    Post subject: combine multiple lines into one Reply with quote

Hello all,

I have a problem that I cant seam to get handle on.

I have a text file that I'm trying to combine into one line. Hears an example. The desired output would be something like this and all on a single line.

acl add name=internal_cobra pos=2 action=allow agent=server \ authmethods=password authneeded=yes destburb=internal nataddr= \ service=cobra sourceburb=internal \ comments='Allow access to Cobra, inside only' \ lastchangedby='root on 12/28/03 10:28:36'



acl add name=internal_cobra pos=2 action=allow agent=server \
authmethods=password authneeded=yes destburb=internal nataddr= \
service=cobra sourceburb=internal \
comments='Allow access to Cobra, inside only' \
lastchangedby='root on 12/28/03 10:28:36'
acl add name=login_console pos=3 action=allow agent=server \
authmethods=password authneeded=yes destburb=Firewall \
nataddr=host:localhost service=console sourceburb=Firewall \
lastchangedby='root on 12/28/03 10:28:36'
acl add name=deny_hackers pos=4 action=deny agent=proxy authneeded=no \
destburb=internal nataddr= source=netgroup:deny_ext sourceburb=external \
comments='Questionable access' lastchangedby='root on 12/28/03 10:28:36'



Any Ideas.
Back to top
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Fri Jan 09, 2004 2:19 pm    Post subject: Reply with quote

Step through your file line by line and add each one to the same variable. Like this

Code:

  list create,1
  list loadfile,1,yourinputfile
  repeat
    %%line = @next(1)
    %%outputline = %%outputline%%line
  until @equal(@index(1),@count(1))


After that you should have everything in one line in %%outputline

Greetz
Dr. Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
bbelcher
Contributor
Contributor


Joined: 30 Jul 2002
Posts: 172

PostPosted: Fri Jan 09, 2004 3:24 pm    Post subject: Reply with quote

I left out one little problem.

I would like to combine each line the starts with acl with the lines below it. Then combine another line starting with the next line starting with acl.

example.

acl add name=internal_cobra pos=2 action=allow agent=server \ authmethods=password authneeded=yes destburb=internal nataddr= \ service=cobra sourceburb=internal \ comments='Allow access to Cobra, inside only' \ lastchangedby='root on 12/28/03 10:28:36'


acl add name=internal_cobra pos=2 action=allow agent=server \ authmethods=password authneeded=yes destburb=internal nataddr= \ service=cobra sourceburb=internal \ comments='Allow access to Cobra, inside only' \ lastchangedby='root on 12/28/03 10:28:36'


Thanks for the help.
Back to top
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Jan 09, 2004 4:07 pm    Post subject: Reply with quote

Something like this?

Code:
  list create,1
  list loadfile,1,yourinputfile
  repeat
    %%line = @next(1)
    if @equal(@substr(%%line,1,3),ACL)
%%outputline = %%outputline@cr()%%line
else
      %%outputline = %%outputline%%line
end
  until @equal(@index(1),@count(1))

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group