/cygdrive/c and C:\ are different - c

I'm trying to run batch scripts via OpenSSH on Windows 8.1 but I'm getting this message:
bash: /cygdrive/c/Windows/System32/boot8.bat: No such file or directory
Somehow, the cygwin environment doesn't map C:\ to /cydrive/c correctly
Just to make sure, this is what mount says:
$ mount
C:/cygwin/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin on / type ntfs (binary,auto)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
So, using cygwin shell I get this result:
$ ls -Al /cygdrive/c/Windows/System32 | grep boot
-rwxrwx---+ 2 TrustedInstaller TrustedInstaller 3072 Aug 22 06:14 api-ms-win-base-bootconfig-l1-1-0.dll
-rwxrwx---+ 2 TrustedInstaller TrustedInstaller 3170304 Jun 18 14:43 boot.sdi
-rwxrwx---+ 2 TrustedInstaller TrustedInstaller 79360 Aug 22 05:49 bootcfg.exe
If I however use the cmd window I can see the file:
C:\Windows\System32>dir | findstr boot
22/08/2013 12:21 165,376 bcdboot.exe
18/06/2013 16:08 3,170,304 boot.sdi
01/08/2013 15:24 290 boot7.bat
04/11/2013 16:00 298 boot8.bat
22/08/2013 12:15 87,040 bootcfg.exe
22/08/2013 10:17 13,312 bootim.exe
22/08/2013 13:45 109,408 bootsect.exe
22/08/2013 12:44 2,560 bootstr.dll
22/08/2013 10:07 3,311,616 bootux.dll
19/11/2013 16:42 307 bootxp.bat
Using the windows explorer, I can see the boot8.bat too.
It works under Windows XP and Windows 7. It doesn't matter whether or not you use capital letters for the Windows and system32 directory . I had this problem before, where I would edit files with notepad++ and when I later opened them with notepad they didn't change.
Any ideas?

try
ls -Al /cygdrive/c/Windows/sysnative | grep boot

Related

linux azure web app not showing my reactjs app

I created a Reactjs web app using the npx create-react-app and created an azure ci/cd pipeline to push the build folder to my Linux web app instance.
i also specified startup command:
pm2 serve /home/site/wwwroot --no-daemon --spa
I verified that the build folder content is in the wwwroot folder but my Linux web app shows nothing.
my web app url: https://linux--dev.azurewebsites.net/
my web app content:
$ ls /home/site/wwwroot -al
total 37
drwxrwxrwx 2 nobody nogroup 4096 Mar 16 10:21 .
drwxrwxrwx 2 nobody nogroup 0 Mar 16 10:21 ..
-rwxrwxrwx 1 nobody nogroup 1092 Mar 16 10:21 asset-manifest.json
-rwxrwxrwx 1 nobody nogroup 3870 Mar 16 10:21 favicon.ico
-rwxrwxrwx 1 nobody nogroup 3010 Mar 16 10:21 index.html
-rwxrwxrwx 1 nobody nogroup 5347 Mar 16 10:21 logo192.png
-rwxrwxrwx 1 nobody nogroup 9664 Mar 16 10:21 logo512.png
-rwxrwxrwx 1 nobody nogroup 492 Mar 16 10:21 manifest.json
-rwxrwxrwx 1 nobody nogroup 67 Mar 16 10:21 robots.txt
drwxrwxrwx 2 nobody nogroup 0 Mar 16 10:21 static
2021-03-16T11:23:14.156072674Z _____
2021-03-16T11:23:14.156107475Z / _ \ __________ _________ ____
2021-03-16T11:23:14.156112975Z / /_\ \___ / | \_ __ \_/ __ \
2021-03-16T11:23:14.156116975Z / | \/ /| | /| | \/\ ___/
2021-03-16T11:23:14.156120475Z \____|__ /_____ \____/ |__| \___ >
2021-03-16T11:23:14.156124075Z \/ \/ \/
2021-03-16T11:23:14.156127375Z A P P S E R V I C E O N L I N U X
2021-03-16T11:23:14.156130575Z
2021-03-16T11:23:14.156133676Z Documentation: http://aka.ms/webapp-linux
2021-03-16T11:23:14.156136776Z NodeJS quickstart: https://aka.ms/node-qs
2021-03-16T11:23:14.156139976Z NodeJS Version : v14.15.1
2021-03-16T11:23:14.156143076Z Note: Any data outside '/home' is not persisted
2021-03-16T11:23:14.156146376Z
2021-03-16T11:23:14.318873080Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2021-03-16T11:23:14.318893181Z Could not find operation ID in manifest. Generating an operation id...
2021-03-16T11:23:14.318897181Z Build Operation ID: 9baf36d5-1dca-413f-929a-d66115f66772
2021-03-16T11:23:14.845130025Z Environment Variables for Application Insight's IPA Codeless Configuration exists..
2021-03-16T11:23:15.173100881Z Writing output script to '/opt/startup/startup.sh'
2021-03-16T11:23:15.352933180Z Running #!/bin/sh
2021-03-16T11:23:15.369142014Z
2021-03-16T11:23:15.369169414Z # Enter the source directory to make sure the script runs where the user expects
2021-03-16T11:23:15.369175515Z cd "/home/site/wwwroot"
2021-03-16T11:23:15.369179015Z
2021-03-16T11:23:15.369182315Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH
2021-03-16T11:23:15.369185715Z if [ -z "$PORT" ]; then
2021-03-16T11:23:15.369189115Z export PORT=8080
2021-03-16T11:23:15.369192715Z fi
2021-03-16T11:23:15.369195915Z
2021-03-16T11:23:15.369200215Z PATH="$PATH:/home/site/wwwroot" pm2 serve /home/site/wwwroot --no-daemon --spa
2021-03-16T11:23:15.381752696Z /opt/startup/startup.sh: 11: /opt/startup/startup.sh: pm2: not found
did I miss something?
Try to use npx serve -s in your startup command.
It works for me.

Nagios Tool, total running time for the tool

Is there any way to check for how long the NAGIOS TOOL runs? I mean when the tool started running and the time up till now.
Nagios is running in a remote machine, in which I have access (through ssh). I have both credentials for accessing the machine and credentials just to see the Stats from Nagios on this machine
I tried System->Process Info, but I do not have privileges to view such information.
Is there any other way, through terminal?
You can use nagiostats to check the uptime of a Nagios instance. See: https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/nagiostats.html
[nagios#lanman ~]# /usr/local/nagios/bin/nagiostats -c /usr/local/nagios/etc/nagios.cfg
Nagios Stats 3.0prealpha-05202006
Copyright (c) 2003-2007 Ethan Galstad (www.nagios.org)
Last Modified: 05-20-2006
License: GPL
CURRENT STATUS DATA
------------------------------------------------------
Status File: /usr/local/nagios/var/status.dat
Status File Age: 0d 0h 0m 9s
Status File Version: 3.0prealpha-05202006
Program Running Time: 0d 5h 20m 39s <------------
Nagios PID: 10119
Used/High/Total Command Buffers: 0 / 0 / 64
Used/High/Total Check Result Buffers: 0 / 7 / 512
...
Find the nagios.log file, it's likely in the var directory under the Nagios installation. Then..
grep "Nagios.*starting" nagios.log | tail -1
Grab the epoch time (first field), and convert it to local.
date -d #1580045430
Sun Jan 26 07:30:30 CST 2020
All in one, assuming the nagios.log is in the current directory.
date -d #$(grep "Nagios.*starting" nagios.log | tail -1 | awk '{print $1}' | sed 's/\[//;' | sed 's/\]//;')
Sun Jan 26 07:30:30 CST 2020

Choose BSD or sys5 style when creating file in linux

When I create file in linux default group owner becomes gid of process which creates file. If I add SGID to parent directory file will inherit parent directory owner group. Also I can change fs mount options to behave either like sys5 or like BSD.
What if I want to choose this option regardless directory permissions and fs mount options? Is there c function option or syscall parameter which allows you to choose group owner?
$ find . -ls
262 4 drwxrwxr-x 4 devops devops 4096 Apr 24 18:01 .
999 4 drwxrwxr-x 2 devops root 4096 Apr 24 18:03 ./dir1
6093 4 drwxrwsr-x 2 devops root 4096 Apr 24 18:03 ./dir2
$ touch dir1/file dir2/file
$ find . -ls
262 4 drwxrwxr-x 4 devops devops 4096 Apr 24 18:01 .
999 4 drwxrwxr-x 2 devops root 4096 Apr 24 18:04 ./dir1
5576 0 -rw-rw-r-- 1 devops devops 0 Apr 24 18:04 ./dir1/file
6093 4 drwxrwsr-x 2 devops root 4096 Apr 24 18:04 ./dir2
6094 0 -rw-rw-r-- 1 devops root 0 Apr 24 18:04 ./dir2/file
$
And I wish to have something like that:
$ mytouch -s BSD dir1/file1
$ mytouch -s sys5 dir1/file2
$ find dir1 -ls
999 4 drwxrwxr-x 2 devops root 4096 Apr 24 18:10 dir1
6213 0 -rw-rw-r-- 1 devops root 0 Apr 24 18:10 dir1/file1
6214 0 -rw-rw-r-- 1 devops devops 0 Apr 24 18:10 dir1/file2
$
Chances are, you can't.
The implementation of sticky bits exists entirely within the kernel, and there are no options to open() or creat() which control how it operates.
Your program could conceivably call chown() to manually reset the group of the file after creating it. However, this would only work reliably if your process is running as root, or as a member of the group that owns the parent directory.

"bare linefeeds received in ASCII mode" warning when listing directory on my FTP server

I am creating an FTP server as a school project, most of the commands are working and I almost nailed PORT (active mode for data transfer).
Launching my server using ftp like such:
ftp localhost 4242 // where 4242 is the port on which my server is listening
And using the command ls after logging in, I receive a working ls output followed by this message:
WARNING! 8 bare linefeeds received in ASCII mode
File may not have transferred correctly.
Please note that when using ls in ftp, it switches automatically to Active Mode before using the LIST command.
What does this error signify?
Full output:
200 Active Mode Enabled.
150 Directory listing.
total 56
drwxrwxr-x 4 kade_c kade_c 4096 mai 12 15:24 .
drwxr-xr-x 38 kade_c kade_c 4096 mai 12 14:58 ..
drwxrwxr-x 8 kade_c kade_c 4096 mai 12 15:17 .git
-rw-rw-r-- 1 kade_c kade_c 1726 mai 11 10:35 Makefile
-rw-rw-r-- 1 kade_c kade_c 161 mai 11 11:43 README.txt
-rwxrwxr-x 1 kade_c kade_c 29368 mai 12 15:24 server
drwxrwxr-x 4 kade_c kade_c 4096 mai 2 18:40 server_src
WARNING! 8 bare linefeeds received in ASCII mode
File may not have transferred correctly.
226 LIST complete.
And finally, here is the part of the code that creates, and connects to the socket and does the ls -la:
server_write(client, "150 Directory listing.\r\n");
if (connect_data(client) == -1) // Creates socket and connects to it
{
server_write(client, "520 Impossible to reach client.\r\n");
return;
}
ofd = xdup(1);
xdup2(client->data.socket, 1);
system("ls -la");
xdup2(ofd, 1);
server_write(client, "226 LIST complete.\r\n");
close_data(client, -1);
This issue is because you are downloading files in ASCII mode. Switching to binary mode will make the warning disappear.
Once you login to the FTP server, type binary and then start downloading.
ftp> binary
200 Type set to I.
You only have to run this command once per FTP session.
I'd guess that you send LF's to the client, and the client (rightly) expects CRLF's and warns about those missing CR's.
According to FTP specification, RFC 959, section 3.4. Transmission modes, in the ASCII mode, you need to use CRLF exclusively:
For the purpose of standardized transfer, the sending host will
translate its internal end of line or end of record denotation
into the representation prescribed by the transfer mode and file
structure, and the receiving host will perform the inverse
translation to its internal denotation. ... End-of-line in an ASCII file with no
record structure should be indicated by <CRLF>

Format file size in Unix in readable format

When I do ls -l I get
-rw-r--r-- 1 jboss admin **26644936** Sep 1 21:23 MyBig.war
How do I print it as below
-rw-r--r-- 1 jboss admin **26,644,936** Sep 1 21:23 MyBig.war
The proper way to format ls output is to specify BLOCK_SIZE.
Saying:
BLOCK_SIZE="'1" ls -l
would achieve your desired result.
Quoting from the above link:
Some GNU programs (at least df, du, and ls) display sizes in “blocks”.
You can adjust the block size and method of display to make sizes
easier to read.
A block size specification preceded by ‘'’ causes output sizes to be
displayed with thousands separators.
Using sed:
$ ls_output='-rw-r--r-- 1 jboss admin 26644936 Sep 1 21:23 MyBig.war'
$ echo $ls_output | sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta'
-rw-r--r-- 1 jboss admin 26,644,936 Sep 1 21:23 MyBig.war
Above sed command repeatedly replace the last 4 digits #### with #,###.
-e :a: Make a label named a for t command.
ta: Jump to a if substitution was successful.

Resources