Search code examples
shellbsd

Rewriting Sysctl output to a file in NetBSD


I am writing a script, while alloting a kernel memory thro' kmem_zalloc() the return address is a pointer and I can't able to capture in any mode. Redirecting to standard output didn't work. how to write this into a file, or to some environment variable. Anyway storing the return address didn't works. Very peculiar.

sysctl -n -w ddb.command="call kmem_zalloc(240,1)"0xf7bdb858

It directly prints next to the command I typed. How to get the address into script as variable or a file.

Thanks, Paavaanan


Solution

  • I think you mean this:

    result=$(sysctl -n -w ddb.command="call kmem_zalloc(240,1)")
    

    or if your shell is older, you may need to use

    result=`sysctl -n -w ddb.command="call kmem_zalloc(240,1)"`
    

    Then you can do:

    echo $result
    0xf7bdb858