Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Giving command line arguments to executable being run with ltrace/strace

The title says it all friends!

How do I give command line arguments to an executable whose execution I want to monitor using ltrace/strace ?

For example, if the executable is 'a.out' and I want to store ltrace's output in a file 'out.txt' and 'arg1' is a command line argument that I want to pass to the execuable, then the command I tried is this "ltrace ./a.out -o arg1 out.txt"

The problem is my program is designed to work only for a single command line argument, so when I run the above command, my program interprets this as multiple command line arguments and stops execution after printing a "Usage" message (it is actually designed to do this but here I want to monitor the library calls it is making).

Can someone please help me out ? Thanks in advance. :)

like image 885
Iceflame007 Avatar asked Feb 13 '23 03:02

Iceflame007


1 Answers

Try passing -o before the command to execute:

ltrace -o out.txt ./a.out arg1

This way ltrace will get -o out.txt and then will exec a.out, passing to it the rest of the command line.

like image 175
cnicutar Avatar answered Feb 15 '23 12:02

cnicutar