I was wondering whether or not it is possible to time out an input/output redirection in Linux. Meaning that I would like to redirect certain input/output to a file just for a time span of 2s for instance. In a practical case, I am looking to cat the tty0 to a file only during 2s How can I achieve this?
Tag: file-io
How to find a string in a file and write a new string immediate next line of that search string in a file using C
I need a suggestion to find and write strings in a file using c program. For example, File.txt has following contents Here, I want to search a string “ddddd” and write new string (“MMMM NNNN”) after this line like File will have following contents after addition of new string, Following is the example Code that I’m trying to make it
How to split a variable with text content on an empty line [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago. Improve this question how can i split a variable with text content by every empty line? Maybe into an array or something like
Reading Long Values From Sysfs Path With Escape Characters
I am using C file IO to read value from a sysfs interface in linux. Path and sample value of the register is as follows: Code: Added after intel-rapl to take into account unknown escape sequence The code compiles without any error, but in the output file I am getting value as 0. Is this due to how I
How one can safely serialize std::basic_istream::pos_type?
In one of my projects I have to cache positional information about certain data chunks found in large files. I’ve already implemented a small API built around std::basic_istream<char>::pos_type placed in maps. Now I need to serialize these descriptors into a bytestream and write them on a disk for further usage (on other *nix-machines as well). I have read that this
Making a virtual file in Linux
I’m working with some existing software that I cannot change, and it loads its config data from a bunch of config files, all following the same naming scheme – let’s say, file_param1.conf, file_param2.conf, file_param3.conf etc. The difference between the content of the files is just param1 vs param2 vs param3, so a typical config file will look like or Is
Errors opening a file in c
currently I’m having problems with the function below trying to open a file, no matter what I give it the function can’t seem to open the file. I’m currently passing in “./input.txt” which is a file in the same directory as the executable. Is there anything blatantly wrong with the code that you guys can see? Answer You are returning
Python cron job file access
I have a tiny Python script that needs to read/write to a file. It works when I run it from the command line (since I am root, it will) , but when the cron job runs it cannot access the file. The file is in the same folder as the script and is (should) be created from the script. I’m
pass stdout as file name for command line util?
I’m working with a command line utility that requires passing the name of a file to write output to, e.g. The only thing it writes to stdout is a message that indicates that it ran successfully. I’d like to be able to pipe everything that is written to output.txt to another command line utility. My motivation is that output.txt will
200,000 images in single folder in linux, performance issue or not?
I have a php/mysql website with over 200,000 images in single folder (linux server). I don’t think, that I will never need to see them in file explorer, instead they will be viewed on website on their individual pages. They are just displayed in product page on website. File system is ext3. so is it wise to save them in