I have a bat script that I’d like to make work on windows/Mac/linux, but I read .bat is only for windows. How can I make this script work on Mac and linux, or what type of script can I write that would work on all 3. Answer If you don’t want to step up to a language like C, I
Tag: macos
Difference between bash pid and $$
I’m a bash scripting beginner, and I have a “homework” to do. I figured most of the stuff out but there is a part which says that I have to echo the pid of the parent bash and the pid of the two subshells that I will be running. So I looked online and found this (The Linux documentation project):
Compiling C Program on OS X to Run on Linux
I have a pretty simple C program that does some cryptographic calculations using only standard library functions. I will be running the program on Ubuntu (10.04, 32 bit) and compiled it on OS X 10.6 using cc with the -m32 flag. When I tried to run it on Ubuntu I got the error message “cannot execute binary file.” When I
Mach-O’s two-level namespace symbol resolution in ELF/linux
Anyone know of an equivalent to Mach-O’s two-level namespace symbol resolution in ELF/linux? I want code that links to lib+sym, not sym. I’m trying to do what could best be described as precompilation of what normally would be a JIT compilation. I’d like to get a compile time binding of symbols, that normally would be done by a dlopen/dlsym. However,
How to run process in terminal with reading only permission for given directory
I am trying to run a process in my terminal but I don’t trust the application that much. Is there is a way to run that application with just read permission from selected directory? I am using macOS. Answer As knittl told, you can use chroot for making jail. For the more complex things, MAC have MAC, (mean OS X
Is it possible to set pthread CPU affinity in OS X?
In Linux there is a sched_setaffinity() function defined in sched.h, but I can’t seem to find anything like that in Mac OS X 10.6 pthreads implementation… If it is not possible to set affinity, what is the default policy in OS X? Answer Mac OS X has Thread Affinity API and you can use it with pthread ID as thread_policy_set(pthread_mach_thread_np(pthreadId),
How to obtain total available disk space in Posix systems?
I’m writing a cross-platform application, and I need the total available disk space. For posix systems (Linux and Macos) I’m using statvfs. I created this C++ method: Unfortunately I’m getting quite strange values I can’t understand. For instance: f_blocks = 73242188 f_bsize = 1048576 f_bfree = 50393643 … Are those values in bits, bytes or anything else? I read here
single common address space for all tasks
How to give single common address space for all tasks. IF its happening like this can we avoid virtual to physical memory mapping. I f all task sharing common address space then how can we avoid virtual to physical memory mapping. Answer I’m not sure why you would want to disable virtual memory mapping – it’s a built in function
The conventional location for storing my Java libraries and applications in UNIX based systems
I usually store the Java applications and JAR files that I download from the Web in the ~/Java folder on my computer (an OS X machine). I have been doing this since the days when I was a Windows user. However I think in UNIX based systems user local apps are conventionally stored in another directory. I have a feeling
Pipe to/from the clipboard in a Bash script
Is it possible to pipe to/from the clipboard in Bash? Whether it is piping to/from a device handle or using an auxiliary application, I can’t find anything. For example, if /dev/clip was a device linking to the clipboard we could do: Answer 2018 answer Use clipboard-cli. It works with macOS, Windows, Linux, OpenBSD, FreeBSD, and Android without any real issues.