How to find a setuid file by using the time which it was created - opensuse

I'm a newbie to OpenSUSE and playing around with the terminal commands.
What i have already done is to create a .txt file and set a setuid for it and hidden it.
What i wanted to know is, how can i find that particular file using the time which it has been created?
ie: Files which has been modified within 30 minutes of time.
Any help would be appreciated.

Something like this should work:
find / -type f -mmin +0 -mmin -30 -perm +6000

Related

PDI - Collecting File From FTP Older Than N Day

I have a job that will Collect Data from FTP using Get a file with FTP and I want it's only collect yesterday file or older than n day or base on specific date.
How do that? Is any way or possible?
What I know is Get a file with FTP only copy file directly from FTP to destination folder. So, I can't use any field and assign it into JavaScript variable to create condition.
My requirement is moving only yesterday or ... file from FTP into Location I need, not all of them because I have a lot of file about 30K-40K with various file size and it will took a lot of time if I do that.
Below is the pic what I have design.
There a Scripting/Shell job entry on which you can put any shell script, including :
find . -mindepth 1 -maxdepth 1 -mtime -7 -exec mv -t /destination/path {} +
For eplanation on the shell script have a look there : https://unix.stackexchange.com/questions/207679/moving-files-modified-after-a-specific-date
By using the 'Get File Names' step in a transformation, you can access your FTP files (via VFS) and their atributes, namely the 'lastmodifiedtime'.
With this information you can do a simple filter by dates, and only download the files which are older than N days, or any other filter you require. With that in hand you can move, download or any other file related action you desire.

Using python to perform multiple Unix commands

I am a computational chemistry student and I need to create 100 directories and copy several python programs into each of them before submitting each one to my schools cluster to test the effectiveness of a program I am writing. Rather then typing mkdir test1, mkdir test2,... mkdir test100 and then cp ...... hundreds of times I'm hoping to make a python program to do all that work for me. I have seen several posts that are a bit too advanced for me to figure out how to do what they are saying so i'm hoping someone knows how to do what I am trying to do.
You can start by importing os, sys and path.
create a for i loop with range till 100.
get current working directory as the folder_path
create name = "test"
in loop do folder_name=name+str(i) use test_path=path.join(folder_path,folder_name) and then do following:
if not os.path.exists(test_path):
os.makedirs(test_path)
This will make directory if not existing.
Then for copying the files into them, you can use the same loop and after step 5 you can move the files in them.
You can refer this simple example to copy many files into a given directory from another directory.
I hope this helps for you to get a clearer idea and also gives you work to do :P :D

monitor changes in a folder windows 7

Ultimately, I want a way (a free way) to monitor changes in a folder and then output those changes to text file. Now this would need to be done programmatically as im using autohotkey to start the process and id like it if it was unseen by the user. I've tried copying the contents of the folder to text file before the change then after the change then using findstr to compare the two and only output the difference to text file. But, findstr outputs false positives. It would output file names as differences even though I can visually confirm they are the same in both files. I need something similar to findstr.
I need something to work like this:
file1.txt
file1.mp3
file2.mp3
file3.mp3
file2.txt
file1.mp3
file2.mp3
file3.mp3
file4.mp3
diff.txt
file4.mp3
Findstr works exactly how I need it to work except for the errors.
findstr /lv /g:file1.txt file2.txt>diff.txt
The error I speak of is with the case sensitivity on, I get 2 files in diff.txt that I know are the same in file1.txt and file2.txt. With case sensitivity off, I get like 30 0r 40 files that are the same in both.
Autohotkey has a very round-about way to accomplish this but I would much prefer a simpler way. Either batch, vbs, or anything else that will run natively on windows 7 or a standalone exe. Something relatively simple and free.
What I am trying to achieve is whatever file is added to the folder, a text file is then created, with the same file name minus the extension, and added to dropbox then IFTTT detects the file and notifies me via sms that 'filename' has finished downloading.
I finished and perfected the method of texting the download link to my pc (via a combination of AHK, batch and IFTTT) which automatically downloads the file. Now I just want a way to be notified its done.

a program to monitor a directory on Linux

There is a directory where a buddy adds new builds of a product.
The listing looks like this
$ ls path-to-dir/
01
02
03
04
$
where the numbers listed are not files but names of directories containing the builds.
I have to manually go and check every time whether there is a new build or not. I am looking for a way to automate this, so that the program can send an email to some people (including me) whenever path-to-dir/ is updated.
Do we have an already existing utility or a Perl library that does this?
inotify.h does something similar, but it is not supported on my kernel (2.6.9).
I think there can be an easy way in Perl.
Do you think this will work?
Keep running a loop in Perl that does a ls path-to-dir/ after, say, every 5 minutes and stores the results in an array. If it finds that the new results are different from the old results, it sends out an email using Mail or Email.
If you're going for perl, I'm sure the excellent File::ChangeNotify module will be extremely helpful to you. It can use inotify, if available, but also all sorts of other file-watching mechanisms provided by different platforms. Also, as a fallback, it has its own watching implementation, which works on every platform, but is less efficient than the specialized ones.
Checking for different ls output would send a message even when something is deleted or renamed in the directory. You could instead look for files with an mtime newer than the last message sent.
Here's an example in bash, you can run it every 5 minutes:
now=`date +%Y%m%d%H%M.%S`
if [ ! -f "/path/to/cache/file" ] || [ -n "`find /path/to/build/dir -type f -newer /path/to/cache/file`" ]
then
touch /path/to/cache/file -t "$now"
sendmail -t <<< "
To: aaa#bbb.ccc
To: xxx#yyy.zzz
Subject: New files found
Dear friend,
I have found a couple of new files.
"
fi
Can't it be a simple shell script?
while :;do
n = 'ls -al path-to-dir | wc -l'
if n -gt old_n
# your Mail code here; set old_n=n also
fi
sleep 5
done
Yes, a loop in Perl as described would do the trick.
You could keep a track of when the directory was last modified; if it hasn't changed, there isn't a new build. If it has changed, an old build might have been deleted or a new one added. You probably don't want to send alerts when old builds are removed; it is crucial that the email is sent when new builds are added.
However, I think that msw has the right idea; the build should notify when it has completed the copy out to the new directory. It should be a script that can be changed to notify the correct list of people - rather than a hard-wired list of names in the makefile or whatever other build control system you use.
you could use dnotify it is the predecessor of inotify and should be available on your kernel. It is still supported by newer kernels.

Resetting detection of source file changes

Sometimes I have to work on code that moves the computer clock forward. In this case some .cpp or .h files get their latest modification date set to the future time.
Later on, when my clock is fixed, and I compile my sources, system rebuilds most of the project because some of the latest modification dates are in the future. Each subsequent recompile has the same problem.
Solution that I know are:
a) Find the file that has the future time and re-save it. This method is not ideal because the project is very big and it takes time even for windows advanced search to find the files that are changed.
b) Delete the whole project and re-check it out from svn.
Does anyone know how I can get around this problem?
Is there perhaps a setting in visual studio that will allow me to tell the compiler to use the archive bit instead of the last modification date to detect source file changes?
Or perhaps there is a recursive modification date reset tool that can be used in this situation?
I would recommend using a virtual machine where you can mess with the clock to your heart's content and it won't affect your development machine. Two free ones are Virtual PC from Microsoft and VirtualBox from Sun.
If this was my problem, I'd look for ways to avoid mucking with the system time. Isolating the code under unit tests, or a virtual machine, or something.
However, because I love PowerShell:
Get-ChildItem -r . |
? { $_.LastWriteTime -gt ([DateTime]::Now) } |
Set-ItemProperty -Name "LastWriteTime" -Value ([DateTime]::Now)
I don't know if this works in your situation but how about you don't move your clock forward, but wrap your gettime method (or whatever you're using) and make it return the future time that you need?
Install Unix Utils
touch temp
find . -newer temp -exec touch {} ;
rm temp
Make sure to use the full path when calling find or it will probably use Windows' find.exe instead. This is untested in the Windows shell -- you might need to modify the syntax a bit.
I don't use windows - but surely there is something like awk or grep that you can use to find the "future" timestamped files, and then "touch" them so they have the right time - even a perl script.
1) Use a build system that doesn't use timestamps to detect modifications, like scons
2) Use ccache to speed up your build system that does use timestamps (and rebuild all).
In either case it is using md5sum's to verify that a file has been modified, not timestamps.