unix

How do I pass Shell parameters to Perl script?

时光怂恿深爱的人放手 提交于 2021-01-28 19:07:21
问题 I am trying to find dates with in a certain format, I have done it before with perl( strftime ), but that time I mentioned a static time, this time i need a variable $CURRENT_DAY here. Below is the issue, when equate the CURRENT_DAY by using DAYHOUR=86400 and an integer, the variable is giving the right time, but once I put $CURRENT_DAY variable in the statement, the date would not decrease. $ DAYHOUR=86400 $ DAY=1 $ CURRENT_DAY=`echo $(($DAYHOUR*$DAY))` $ DD=`perl -e 'use POSIX; print

How to use environment variables in blender

六月ゝ 毕业季﹏ 提交于 2021-01-28 15:31:12
问题 I added a enviroment variable writing in the ~/.bashrc file this two line var="stuff.." export var using the python interpreter in a normal terminal this two lines of code works import os print(os.environ['var']) but in a blender python console it generate a KeyError so printing os.environ list i can see that there isn't a item with 'var' as key So i think that is a problem with the environment settings in unix system. Can anyone help me and explain how export the environment variables for

Send grepped tail output to netcat

我怕爱的太早我们不能终老 提交于 2021-01-28 14:27:08
问题 I am trying to run the following command, and nothing is getting sent to netcat tail -F file.txt | grep test | nc host 9999 If I remove the grep, the tail successfully is followed and sent to netcat. If I just run the following, data comes back, so I know that data should be getting sent to the nc pipe: tail -F file.txt | grep test Any ideas? UPDATE I added the following to unbuffer the piped output and nothing goes through: tail -F file.txt | stdbuf -o0 grep test | nc host 9999 When I turn

Appending 0's to a file in unix/bash if the line is less than a fixed length

浪子不回头ぞ 提交于 2021-01-28 13:57:39
问题 I am looking for a way in which to append 0's to the end of multiple lines in a file if they are less than 66 characters in length so that the total line length equals 66. Here's an example of the file format (... denotes preceding 56 characters): $cat file1 ...1234567891 ...123456 ... ...12345678 Ideal format: ...1234567891 ...1234560000 ...0000000000 ...1234567800 回答1: GNU awk solution: $ awk '{s=$0; while(length(s)<66) s=s "0"; print s}' file1 or even shorter: $ awk '{while(length<66) $0=

Why this example using mutex is less efficient compared to another one with additional condition variable?

半腔热情 提交于 2021-01-28 11:01:42
问题 An example from The Linux Programming Interface : In the producer threads, we would have code such as the following: static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static int avail = 0; /* Code to produce a unit omitted */ s = pthread_mutex_lock(&mtx); if (s != 0) errExitEN(s, "pthread_mutex_lock"); avail++; /* Let consumer know another unit is available */ s = pthread_mutex_unlock(&mtx); if (s != 0) errExitEN(s, "pthread_mutex_unlock"); And in the main (consumer) thread, we could

How can I remove the last n characters of filenames in a certain directory (in Mac terminal)- unix?

流过昼夜 提交于 2021-01-28 05:43:21
问题 I am trying to rename using "mv", because "rename" command doesn't work in my Mac terminal. I have a bunch of files named DTM001_ACGGT-TTAGGC.fq DTM156_GGTTG-ACAGTG.fq ...etc I wish to rename them to DTM001.fq DTM156.fq I suppose the easier way is to remove the last 13 characters before the file extension? I tried these links: mac os x terminal batch rename Rename file by removing last n characters Removing last n characters from Unix Filename before the extension but none have worked for me,

Java “package does not exist” error in UNIX

↘锁芯ラ 提交于 2021-01-28 03:46:31
问题 My project directory structure is something like this: ProjectName/coursesRegistration/src/coursesRegistration/util When I do "import coursesRegistration.util.FileProcessor; " in Eclipse it works but when I try this on UNIX (using command line compilation) it gives me an error saying "error: package coursesRegistration.util does not exist". Maybe I am missing something very basic, does anyone know what may be the problem? 回答1: If you're trying to do command-line compilation, this is probably

Bash “command not found” error

删除回忆录丶 提交于 2021-01-28 03:03:17
问题 I am trying to edit my .bashrc file with a custom function to launch xwin. I want it to be able to open in multiple windows, so I decided to make a function that accepts 1 parameter: the display number. Here is my code: function test(){ a=$(($1-0)) "xinit -- :$a -multiwindow -clipboard &" } The reason why I created a variable "a" to hold the input is because I suspected that the input was being read in as a string and not a number. I was hoping that taking the step where I subtract the input

msync equivalent in Windows

混江龙づ霸主 提交于 2021-01-28 02:21:35
问题 what is the equivalent of msync [unix sys call] in windows? I am looking for MSDN api in c,C++ space. More info on msync can be found at http://opengroup.org/onlinepubs/007908799/xsh/msync.html 回答1: FlushViewOfFile Checkout the Python 2.6 mmapmodule.c for an example of FlushViewOfFile and msync in use: /* / Author: Sam Rushing <rushing@nightmare.com> / Hacked for Unix by AMK / $Id: mmapmodule.c 65859 2008-08-19 17:47:13Z thomas.heller $ / Modified to support mmap with offset - to map a

Are there in AIX mechanisms EPOLL/KQUEUE or their equivalents?

[亡魂溺海] 提交于 2021-01-28 00:34:55
问题 Are there in AIX mechanisms EPOLL(Linux2.6)/KQUEUE(FreeBSD)/IO Completion Port(Windows) or their equivalents? And what kind of mechanisms are optimal for AIO on AIX for a large number of network connections? For example according to the Benchmarks, the mechanisms KQUEUE / EPOLL much faster than SELECT. http://libevent.org/ 回答1: I believe poll set is the best choice today. There is also the iocp interfaces which comes from windows. And there are the aio interfaces which use iocp under the