I have an executable program (no source code, just the compiled executable) that was made in windows (.exe extension). It doesn't use any graphics… it simply reads and writes files. I want to be able to run it in a linux shell script so that I don't have to switch operating systems to get my output. Is there a way to use or convert the executable for linux operating systems?
Shell – How to run a windows executable in linux shell script
executableshell-scriptwindows
Related Solutions
Start by using time as per Jon Lin's suggestion:
$ time ls test
test
real 0m0.004s
user 0m0.002s
sys 0m0.002s
You don't say what unix your scripts are running on but strace on linux, truss on Solaris/AIX, and I think tusc on hp-ux let you learn a lot about what a process is doing. I like strace's -c option to get a nice summary:
]$ strace -c ls
test
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
89.19 0.000998 998 1 execve
10.81 0.000121 121 1 write
0.00 0.000000 0 12 read
0.00 0.000000 0 93 79 open
0.00 0.000000 0 16 close
0.00 0.000000 0 2 1 access
0.00 0.000000 0 3 brk
0.00 0.000000 0 2 ioctl
0.00 0.000000 0 4 munmap
0.00 0.000000 0 1 uname
0.00 0.000000 0 6 mprotect
0.00 0.000000 0 2 rt_sigaction
0.00 0.000000 0 1 rt_sigprocmask
0.00 0.000000 0 1 getrlimit
0.00 0.000000 0 30 mmap2
0.00 0.000000 0 8 7 stat64
0.00 0.000000 0 13 fstat64
0.00 0.000000 0 2 getdents64
0.00 0.000000 0 1 fcntl64
0.00 0.000000 0 1 futex
0.00 0.000000 0 1 set_thread_area
0.00 0.000000 0 1 set_tid_address
0.00 0.000000 0 1 set_robust_list
0.00 0.000000 0 1 socket
0.00 0.000000 0 1 1 connect
------ ----------- ----------- --------- --------- ----------------
100.00 0.001119 205 88 total
Do also note that attaching these tracing type programs can slow the program down somewhat.
A shell script is an executable program. That's why type
says that it is one. A shell script is as much an executable command as a perl script, a python script, a native ELF executable, a cross-architecture executable being executed by Qemu through Linux's binfmt_misc mechanism, etc. Any executable file is an executable command, it doesn't matter what interpreter it uses.
As you can tell from my list of examples, the line between “a script” and “not a script” is fuzzy: any executable file that begins with a shebang is a script, but there are executable files that are neither native code nor scripts.
When you execute a program, what language it's written in is irrelevant. So it wouldn't make sense for type
to tell you about it. The job of type
is only to tell you what type of command it is from the point of view of the shell.
A shell script is not the same thing as a function. A function runs inside the shell, and can modify the shell's environment. A shell script is a separate program; this separate program may happen to be written in the same language as the program you're running right now, but that's just a coincidence.
Best Answer
Wine works even for Windows CLI apps.