I will be getting some shell scripts that I, kind of, dont know what they will be doing. But I need to know what I/O operations the script performs (e.g. files they read/access,files they write, folders created...etc).
An example is using strace as follows:
g++ -Wall a.cpp -o hello
I will run it as:
sudo strace -f -e trace=open g++ -Wall a.cpp -o hello 2> output.txt
*WHAT I WANT: * output.txt will have the trace and which files had been accessed (a.cpp and b.h which is used in a.cpp, and output hello)
... [pid 13871] open("a.cpp", O_RDONLY|O_NOCTTY|O_LARGEFILE) = 3 [pid 13871] open("b.h", O_RDONLY|O_NOCTTY|O_LARGEFILE) = 4 ... [pid 13874] open("hello", O_RDWR|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3 ...
strace doesnt handle pipe so if I get a command like
mkdir d2 | cp *.c d2/ it will only detect the first command
strace provide too much info which is fine but if something is more concrete that would be great!
I searched for other tools and utils, and most of them would list info for a running process and I dont want that since the script will be executed immediately and nothing would be in the process list in Ubuntu.
Any ideas on how can I achieve this in Ubuntu?