perl - Generic ways to invoke syscalls from the shell -


i call truncate(const char *path, off_t length) (see man 2 truncate) directly command line or in shell script.

i guess embed c program , compile, run, , remove it.

another short alternative using perl -e "truncate($file,$length)".

questions:

is perl -e "syscall(params...)" common pattern invoke syscalls? how cover other syscalls?

is there common way invoke linux/bsd syscalls shell? instance, using command syscall "truncate($file,$length)"?

thank comments , suggestions. conclude following answers questions:

  1. some scripting languages, e.g., perl, may provide functions resemble or wrap of useful syscalls, i.e., make sense calling shell.
  2. however, there no 1:1 mapping of scripting apis , syscalls , no "common pattern" or tool invoke many different types of syscalls shell.

moreover, generic solution specific problem should not focus on syscalls in first place, rather use generic language or library beginning. instance, file truncation may perl, using perl -e "truncate($file,$length)".


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -