Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, I have i little problem with parsing text. For example i have output 15342 execve("./hahaha\", [kamapo.sh", ["./hahaha\", [kamapo.sh"], [/* 37 vars */]) = 0 and i need parse this ...
  1. #1
    Just Joined!
    Join Date
    Mar 2010
    Posts
    1

    Parsing text string

    Hello, I have i little problem with parsing text. For example i have output

    15342 execve("./hahaha\", [kamapo.sh", ["./hahaha\", [kamapo.sh"], [/* 37 vars */]) = 0

    and i need parse this string ./hahaha\", [kamapo.sh but it is output of strace ang i could be anything in name exept / and \0 and i don`t know how to formulate regexp or what use grep and sed or awk.

    And next problem i need separate same string but only if the file was open successful.

    28134: open("/etc/li"bm\"ap.conf2", O_RDONLY) = -1 ENOENT (No such file or directory)
    28135: open("/etc/lib"map.conf3", O_RDONLY, <unfinished ...>
    28131: open("/etc/lib"map.conf12", O_RDONLY, <unfinished ...>
    28131: <... open resumed>) = 0
    28135: <... open resumed>) = -1 ENOENT (No such file or directory)


    Thanks a lot for some advice. I have been thinking about it for a long and I have no idea

  2. #2
    Just Joined!
    Join Date
    Jun 2007
    Posts
    6
    I don't want to write whole regexp for your IOS project , but I can help you a little.

    In the execve you can rely on the fact, that either every " in file name will be escaped, so you can search for last occurence of ", which is not escaped to get the file name or there will not be an array notation as the second argument. I prefer using (g)awk for this, but you can also use sed.

    In the second example you will have to use an associative array in awk to join unfinished and resumed parts together.

    And don't forget to filter out unsuccessfully opened files using grep -v or sed.

    Good luck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...