For the RTOS I'm writing ( http://www.distortos.org ) I need to run find as part of the build configuration process (from make menuconfig target). For Windows I assume that user has MSYS2 installed, so find.exe is available. The only problem with this particular file is that Windows also has such file in C:/Windows/system32 (supposedly it is something close to grep). So depending on the order of folders in your PATH environment variable you get one or the other if trying to call the file by just the name.
I've found that calling this program as /bin/find from the Makefile or in shell script works both in Windows and on (my) Linux. What is most important - doing it that way always calls find.exe from MSYS2, no matter what is the order of folders in PATH. So I'm wondering - is it OK to call find this way, or maybe it is not portable and I just had luck that it works for me?
It would probably be more portable to refer to it as /usr/bin/find. For example, on Fedora /bin is actually a symlink to /usr/bin, so either works:
bash-4.3$ ls -l /bin/find
-rwxr-xr-x. 1 root root 222608 Dec 28 18:26 /bin/find
bash-4.3$ ls -l /usr/bin/find
-rwxr-xr-x. 1 root root 222608 Dec 28 18:26 /usr/bin/find
But on a recent Ubuntu:
root#69ca68fbe5c0:/# ls -l /bin/find
ls: cannot access /bin/find: No such file or directory
root#69ca68fbe5c0:/# ls -l /usr/bin/find
-rwxr-xr-x. 1 root root 229992 Jan 6 2014 /usr/bin/find
I would recommend not hard-coding the path to find and instead instruct Windows users that they must run your script inside the MSYS2 environment. MSYS2 will put its own bin directories near the beginning of the path so that find always gets the MSYS2 version instead of the Microsoft version.
If you hard-code the path to find then you make things be more brittle than they need to be.
Related
I have a question, I created a script but I need to create a path, to find my cassandra folder to execute cqlsh, this is the route
C:/apache-cassandra-3.11.4/bin/cqlsh
the problem is because I am in windows not in linux, and I want to see if possible to create an a path in case that I need to pass my script to my team. but you know your cassandra db is in another route for that reason I want to do that because I need to execute this script
example
route= /../cassandra3.11.4/bin/cqlsh
$route -k fsainstqual -e "TRUNCATE instrumentmanufacturer"
If you mean you don't know how to mix Windows drive letters and Linux directory handling (which does not have drives), you'll need mounting points, as you can see in following mount excerpt on my PC, where I have a Linux app installed:
Prompt>mount
...
C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000,case=off)
E: on /mnt/e type drvfs (rw,noatime,uid=1000,gid=1000,case=off)
In top of that, on my root directory, I've created symlinks to those mounted directories:
Prompt>cd /
Prompt>$ ls -ltra | grep "\->"
lrwxrwxrwx 2 root root 6 Nov 23 2017 C -> /mnt/c
lrwxrwxrwx 2 root root 6 Nov 14 12:00 E -> /mnt/e
I think it's better to clarify your question buddy.
If you want to change your current directory, you can use "cd" command as in linux shell.
If you want to create a path use "md" or "mkdir" command.
Here is the help in windows OS
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/md
A program requires a java directory location of /usr/java/latest. In many cases this directory does not exist. In order to get the program to run correctly I need to do the following steps:
mkdir -p /usr/java
mkdir -p /usr/java/latest
Then I need to find what java installations are available and symlink them to the above directories:
ll /usr/lib/jvm
I usually choose the latest directory avialable...ie:
drwxr-xr-x. 3 root root 16 Feb 12 2016 java-1.8.0-openjdk-1.8.0.71-2.b15.el7_2.x86_64
and then create a link to /usr/java/latest
ln -s /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.71-2.b15.el7_2.x86_64/jre/lib /usr/java/latest/lib
ln -s /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.71-2.b15.el7_2.x86_64/jre/bin /usr/java/latest/bin
I am trying to create an installation script that automates the above process without having to copy and paste the directory name for the symbolic link. Basically I want to parse the /usr/lib/jvm/ directory for the most recent (or any) available java directory. Then I want to take that and link the lib and bin directories within that directory to the /usr/java/latest directory. Thank you in advance for any type of advice.
I am using the below to find the directory I need.
ls -F /usr/lib/jvm | grep / | sed '$!d' | sed 's:/*$::'
I have some mod_perl code trying to access a file under /tmp ... but it throws a 'no such file or directory' error. I added an 'ls -al /tmp' to my code to see what Perl was seeing inside the directory, and it only gave me . and .. :
drwxrwxrwt. 2 root root 6 Jan 21 13:36 .
drwxrwxrwx. 18 root sysadmin 4096 Nov 22 22:14 ..
In reality there are a mixture of files under /tmp, including some owned by the Apache user. Changing my code to 'ls -al /' gives a correct directory listing (nothing missing).
I tried sudo'ing to the Apache user, and can see under /tmp file, so it must be something mod_perl related.
Ideas? I'm running mod_perl 2.0.8 and Apache 2.4 under CentOS 7. SELinux is set to permissive.
So based on comments the answer here is - it's an RHEL 7 feature.
https://securityblog.redhat.com/2014/04/09/new-red-hat-enterprise-linux-7-security-feature-privatetmp/
PrivateTmp=
Takes a boolean argument. If true sets up a new file system
namespace for the executed processes and mounts a private /tmp
directory inside it, that is not shared by processes outside of
the namespace. This is useful to secure access to temporary files
of the process, but makes sharing between processes via /tmp
impossible. Defaults to false.
I am very puzzled by this problem I am having. I am trying to execute a file in Ubuntu 12.04 LTS via command line. I have a script that calls a program to run and write the results in a hard drive. I changed the permissions and ownership of everything to be wxr. Here is the ls -l of my script (called TEST-star):
-rwxrwxrwx 1 root root 950 Nov 15 13:16 TEST-star
Here is the ls -l of the package my script calls:
-rwxrwxrwx 1 root root 1931414 Nov 10 12:37 STAR
Finally the ls -l of the hard drive mounted in /media/CLC"
drwxrwxrwx 1 root root 8192 Nov 15 13:04 CLC
I have been trying to run it since yesterday and always get a message that I don't have permission to write the results:
EXITING because of FATAL ERROR: could not create output file ./_STARtmp//Unmapped.out.mate1.thread14
Solution: check that you have permission to write this file
I thought if I change the permissions to rwx and run my script as root it would not have a problem (using sudo). Right now I run out of options. Any suggestion would be appreciated. Please let me know what other information you would need solve this issue.
Thank you.
Here is the first line of script I am trying to run:
#!/bin/sh
cd /media/CLC/ANOPHELES-STAR-v2.4f1/; mkdir GambFemAnt1 && cd GambFemAnt1; echo $PWD && echo Starting mapping of GambFemAnt1; /home/aedes/Documents/STAR_2.4.0f1/STAR --genomeDir /media/Galaxy/Galaxy_data/Anopheles/STAR/Genome --readFilesIn /media/Galaxy/Galaxy_data/Anopheles/QC/GambFemAnt1/GambFemAnt1.fastq --runThreadN 23 --outFilterMismatchNmax 4 --outFilterMatchNminOverLread 0.75 --seedSearchLmax 30 --seedSearchStartLmax 30 --seedPerReadNmax 100000 --seedPerWindowNmax 100 --alignTranscriptsPerReadNmax 100000 --alignTranscriptsPerWindowNmax 10000 --outSAMstrandField intronMotif --outFilterIntronMotifs RemoveNoncanonical --outSAMtype BAM SortedByCoordinate --outReadsUnmapped Fastx; mv Aligned.sortedByCoord.out.bam GambFemAnt1.bam; mv Unmapped.out.mate1 GambFemAnt1-unmapped.fastq; cp *.fastq /media/CLC/ANOPHELES-STAR-v2.4f1/UNMAPED-reads/; cd /media/CLC/ANOPHELES-STAR-v2.4f1 && echo $PWD && echo GambFemAnt1 mapping finished;
I also posted a question for the authors of the package.
Turns out all the permissions were set correctly. The problem resigns within the package. I found out that it works using --runThreadN 12 instead of --runThreadN 23.
I use both winsymlinks:native and cygwin symlinks depending on if windows needs to and CAN follow the link. I'd like to have a cygwin way to see what kind of symlink it is since it just sees a symlink but DOS sees the difference. I need to know the diff so I can handle rsyncing/etc/ and have the type of symlink preserved (or recreated).
I have the perms to create the dos native ones and have functions to set either:
$ touch test
# cygwin style symlink
$ CYGWIN= ln -s test t1
# WINDOWS style
$ CYGWIN=winsymlinks:native ln -s test t2
# for good measure make one the DOS way
$ cmd /c mklink t3 test
symbolic link created for t3 <<===>> test
cygwin sees them all as symlinks:
$ ls -l
total 1
lrwxrwxrwx 1 user Users 4 Jun 14 11:06 t1 -> test
lrwxrwxrwx 1 user Users 4 Jun 14 11:06 t2 -> test
lrwxrwxrwx 1 user Users 4 Jun 14 11:06 t3 -> test
-rw-rw-rw-+ 1 user Users 0 Jun 14 11:05 test
Windows knows the native symlinks:
Or as seen from DOS:
$ cmd /c dir /a
Volume in drive C is Windows
Directory of C:\Cygwin-32\tmp
06/14/2014 11:06 AM 22 t1
06/14/2014 11:06 AM <SYMLINK> t2 [test]
06/14/2014 11:06 AM <SYMLINK> t3 [test]
06/14/2014 11:05 AM 0 test
4 File(s) 22 bytes
So how do I tell what kind of symlink it is when viewed in CYGWIN? When I rsync these symlinks, cygwin will make all of them at the destination the kind set in the CYGWIN env var. I would like to keep the symlink type in the rsync'd destination or at the very least go through the source folder, figure out the type and change them at the destination. stat also only reports them as symlinks, does not see the difference.
Adding this section because I HATE the "Why do you need (or want) to do that?" answers:
Why do I mix symlinks? I tried setting my overall CYGWIN env var to CYGWIN=winsymlinks:native and CYGWIN=winsymlinks:nativestrict but during some package installs (mostly using apt-cyg) I have had errors in the extracted TAR of a few packages so I left that out and only call CYGWIN=winsymlinks:native as I need them (if windows needs to follow the link). I think the packages are installed as cygwin symlinks from the initial CYGWIN setup.exe so setting that value globally will create the problem later. I've also had the CYGWIN=winsymlinks:nativestrict setting create an actual "/usr/bin/" folder (can see in explorer) but cygwin has /bin mounted as /usr/bin so you get packages extracted that are not found in cygwin.
And also just because there are some symlinks I DON'T want Windows to know about or follow.
I ended up scripting this. The test in cygwin would be to call a dos command and grep for the info needed.
if fsutil reparsepoint query "$1" | grep -iq "Tag value: Symbolic Link" ; then
echo "Windows Native Symlink"
fi