I have the following code to write data to a file called logdata.ext in a particular format.
echo "###############################################################################" >> logdata.txt
echo " HEADING GOES HERE " >> logdata.txt
echo "###############################################################################" >> logdata.txt
echo " Server : $NAME Time Stamp : $(date)" >> logdata.txt
echo " Mount Point Disk Space Occupied Action Required " >> logdata.txt
echo "===============================================================================" >> logdata.txt
echo "ROOT_DIR $appl% $app_st" >> logdata.txt
echo "share $app_share% $share_st " >> logdata.txt
echo "/tmp $tmp% $tmp_st" >> logdata.txt
echo "/home $home% $home_st" >> logdata.txt
When I am opening the file using
cat logdata.txt
I am getting the following well formatted output
###############################################################################
HEADING GOES HERE
###############################################################################
Server : 198.168.53.45 Time Stamp : Wed Aug 12 06:41:48 PDT 2015
Mount Point Disk Space Occupied Action Required
===============================================================================
ROOT_DIR 64% No
share 94% Yes
/tmp 8% No
/home 69% No
But I tried sending the file logdata.txt to my email ID using the code
cat "logdata.txt" | mailx -s "Disk Space Warning!" myemail#mydomain.com
But the formatting was not as good as in the file.
I got it in the following format
###############################################################################
HEADING GOES HERE
###############################################################################
Server : 198.168.53.45 Time Stamp : Wed Aug 12 06:28:44 PDT 2015
Mount Point Disk Space Occupied Action Required
===============================================================================
ROOT_DIR 64% No
share 94% Yes
/tmp 8% No
/home 69% No
Why am I getting a different format when I send the file to mail?
In command prompt or any editor program, text is displayed in monospaced/fixed width font, in which each character is of same horizontal width. However most likely, your mail client is using any other font (not monospaced) to display the text.
You can either attach the file with the mail, or use html to format the text.
Related
I would like to capture the progress information during downloads.
I have tried, for example from a cmd prompt:
c:\Windows\ncftpget ftp://speedtest.tele2.net/1MB.zip > mylog
c:\Windows\ncftpget ftp://speedtest.tele2.net/1MB.zip >> mylog
c:\Windows\ncftpget ftp://speedtest.tele2.net/1MB.zip > mylog 2>&1
Mylog is always written with 0 bytes, unless the file to be downloaded is already present. In that case I get a 92 byte error message.
The problem seems specific to ncftpget. It works with Windows 10 ftp.
You need to use -d /path/to/log.txt
ncftpget -d /tmp/ncftpget.log <url>
Example output:
2018-12-01 03:49:33 Cmd: USER anonymous
2018-12-01 03:49:33 331: Password required for anonymous
2018-12-01 03:49:33 Cmd: PASS NcFTP#
2018-12-01 03:49:35 530: Login incorrect
2018-12-01 03:49:35 Cmd: QUIT
2018-12-01 03:49:35 221: Goodbye
I want to run rdiff-backup and then switch of the raspberrypi it was running on.
I use the following script:
#!/bin/sh
date > /home/mik/rdiff-backup.log
echo "rsync start" >> /home/mik/rdiff-backup.log
rdiff-backup -v5 --print-statistics offlinebackup#server::/srv/backup /srv/datenserverBackup/backup >> /home/mik/rdiff-backup.log 2>&1
sync
date >> /home/mik/rdiff-backup.log
echo "rdiff-backup end" >> /home/mik/rdiff-backup.log
df -h >> /home/mik/rdiff-backup.log
sync
halt
The log file looks good (for the rdiff-backup part):
Sat 12 Aug 08:20:59 UTC 2017
rsync start
Unable to import win32security module. Windows ACLs
not supported by filesystem at /srv/backup
escape_dos_devices not required by filesystem at /srv/backup
Warning: name offlinebackup not found on system, dropping ACL entry.
Further ACL entries dropped with this name will not trigger further warnings
Using rdiff-backup version 1.2.8
Executing ssh -C offlinebackup#server rdiff-backup --server
-----------------------------------------------------------------
Detected abilities for source (read only) file system:
Access control lists On
Extended attributes On
Windows access control lists Off
Case sensitivity On
Escape DOS devices Off
Escape trailing spaces Off
Mac OS X style resource forks Off
Mac OS X Finder information Off
-----------------------------------------------------------------
Unable to import win32security module. Windows ACLs
not supported by filesystem at /srv/datenserverBackup/backup/rdiff-backup-data/rdiff-backup.tmp.0
escape_dos_devices not required by filesystem at /srv/datenserverBackup/backup/rdiff-backup-data/rdiff-backup.tmp.0
-----------------------------------------------------------------
Detected abilities for destination (read/write) file system:
Ownership changing On
Hard linking On
fsync() directories On
Directory inc permissions On
High-bit permissions On
Symlink permissions Off
Extended filenames On
Windows reserved filenames Off
Access control lists On
Extended attributes On
Windows access control lists Off
Case sensitivity On
Escape DOS devices Off
Escape trailing spaces Off
Mac OS X style resource forks Off
Mac OS X Finder information Off
-----------------------------------------------------------------
Backup: must_escape_dos_devices = 0
Starting increment operation /srv/backup to /srv/datenserverBackup/backup
Processing changed file .
Incrementing mirror file /srv/datenserverBackup/backup
Processing changed file abc
Incrementing mirror file /srv/datenserverBackup/backup/abc
Processing changed file abc/def
Incrementing mirror file /srv/datenserverBackup/backup/abc/def
Processing changed file abc/def/testfile.dxf
Incrementing mirror file /srv/datenserverBackup/backup/abc/def/testfile.dxf
--------------[ Session statistics ]--------------
StartTime 1502526061.00 (Sat Aug 12 08:21:01 2017)
EndTime 1502527913.72 (Sat Aug 12 08:51:53 2017)
ElapsedTime 1852.72 (30 minutes 52.72 seconds)
SourceFiles 151099
SourceFileSize 386321558216 (360 GB)
MirrorFiles 151097
MirrorFileSize 386321447731 (360 GB)
NewFiles 2
NewFileSize 110485 (108 KB)
DeletedFiles 0
DeletedFileSize 0 (0 bytes)
ChangedFiles 1
ChangedSourceSize 0 (0 bytes)
ChangedMirrorSize 0 (0 bytes)
IncrementFiles 4
IncrementFileSize 0 (0 bytes)
TotalDestinationSizeChange 110485 (108 KB)
Errors 0
--------------------------------------------------
The backup is working, but then the script ends right there.
rdiff-backup.log contains the full report of rdiff-backup. But neither the line "rdiff-backup end", nor the output of "df -h".
How can I make it ran to the end?
Thanks for your answers
I finally found a workaround, that solves my problem.
My sciprt which is called after booting from /etc/init.d is calling the other script which does the actual work (i.e. backup my data, and write the log file) as a background task.
/etc/init.d/CallAfterBoot.sh
#!/bin/sh
sleep 30
/home/me/DoBackup.sh & # '&' starts the script in background
/home/me/DoBackup.sh is the script I posted above which is now runing correctly.
Same script running as the same user now behaves differently. There's got to be some bug somewhere, however, it works for me now.
I have some text files where I need to add 1 character to the beginning of every line of the file.
In windows, I found that a quick way to do this was by installing Cygwin and using the following command, which prepends the letter N to every line of the file:
$ sed 's/^/N/' inputFile.txt > outputFile.txt
What I found strange, was that after I added a new character to the front of each line, the file size was almost completely unchanged. I tested this further, to see if I could recreate the problem with the following steps:
Created a text file called "Test.txt", which had 10,000 lines with the word "TEST" on each line.
Created a text file called "TestWithNPrefix.txt" which had 10,000 lines with the word "NTEST" on each line.
Executed the following command to create another file which had 10,000 lines of "NTEST"
$ sed 's/^/N/' Test.txt > "SEDTest.txt"
Results
"Test" and "SEDTest" were almost the exact same size, while "TestWithNPrefix" was 10KB larger.
Test = 59,998 Bytes; SEDTest = 59,999 Bytes; TestWithNPrefix = 69,998 Bytes
When I ran the "fc" command in Command Prompt, it returned that there were no differences between "SEDTest" and "TestWithNPrefix". "FC" between "SEDTest" and "Test" returned "Resync Filed. Files are too different".
Can someone please help me understand what is causing these file size discrepancies?
EDIT: I created the files "Test.txt" and "TestWithNPrefix.txt" in UltraEdit. I just typed out the word "TEST"/"NTEST", then copied and pasted it 10,000 times.
Not an answer, but a comment with formatting:
You seem to be running into some odd situation with DOS versus Unix line endings. I have to ask: How are you creating the files? I would expect 10,000 lines of "TEST\r\n" would be exactly 60,000 bytes in size, not 59,999
On Linux (I don't have access to a cygwin environment at the moment):'
$ yes $'TEST\r' | head -n 10000 > Test
$ ll Test
-rw-r--r-- 1 jackman jackman 60000 Jan 8 13:06 Test
$ sed 's/^/N/' Test > SEDTest
$ ll *Test
-rw-r--r-- 1 jackman jackman 70000 Jan 8 13:06 SEDTest
-rw-r--r-- 1 jackman jackman 60000 Jan 8 13:06 Test
I have been trying to add a PostgreSQL database to my OpenShift online account to no avail. I am a little confused about how to go about it and I thought I could ask for someone to point me to the right direction.
I have the source cloned from https://github.com/crunchyds/openshift-postgres-cartridge and uploaded to my openshift online repo. I tried running the included scripts - setup, control and the likes but get an error each time.
So I figured this is the wrong way to go about deploying it. Can anyone please explain how to go about it or post a link that would help ?
Here's the error message :
source /usr/lib/openshift/cartridge_sdk/bash/sdk
'[' false == true ']'
OO_BASH_SDK=true
echo /var/lib/openshift/54492b5d4382ec8e52000428//app-deployments
/var/lib/openshift/54492b5d4382ec8e52000428//app-deployments
tar xzf /versions/postgresql94.tar.gz
tar (child): /versions/postgresql94.tar.gz: Cannot open: No such file or
directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
client_result 'Starting PostgreSQL server setup ...'
client_out CLIENT_RESULT 'Starting PostgreSQL server setup ...'
local type=CLIENT_RESULT
local 'output=Starting PostgreSQL server setup ...'
local 'IFS_BAK= '
IFS=''
'[' -z 'Starting PostgreSQL server setup ...' ']'
for line in '$output'
echo 'CLIENT_RESULT: Starting PostgreSQL server setup ...'
CLIENT_RESULT: Starting PostgreSQL server setup ...
IFS=''
mkdir -p /var/lib/openshift/54492b5d4382ec8e52000428/app-
root/data//postgresql/9.4/data
mkdir -p /var/lib/openshift/54492b5d4382ec8e52000428/app-
root/data//postgresql/9.4/data/logs
echo 5432
./setup: line 22: /env/PGPORT: No such file or directory
echo /var/lib/openshift/54492b5d4382ec8e52000428/app-root/data//postgresql/9.4/data
./setup: line 23: /env/PGDATA: No such file or directory
echo /var/lib/openshift/54492b5d4382ec8e52000428/app-root/data//versions/postgresql94/bin
./setup: line 24: /env/OPENSHIFT_POSTGRESQL94_PATH_ELEMENT: No such file or directory
echo /versions/postgresql94/lib
./setup: line 25: /env/OPENSHIFT_POSTGRESQL94_LD_LIBRARY_PATH_ELEMENT: No such file or directory
echo /versions/bin
./setup: line 26: /env/OPENSHIFT_POSTGRESQL94_PATH_ELEMENT: No such file or directory
client_result 'Server setup completed successfully ...'
client_out CLIENT_RESULT 'Server setup completed successfully ...'
local type=CLIENT_RESULT
local 'output=Server setup completed successfully ...'
local 'IFS_BAK= '
IFS=''
'[' -z 'Server setup completed successfully ...' ']'
for line in '$output'
echo 'CLIENT_RESULT: Server setup completed successfully ...'
CLIENT_RESULT: Server setup completed successfully ...
IFS=''
When you add the cartridge you need to pass in the url for the cartridge.
Are you trying to run this in online?
If so I am not sure if this is supposed to work in online so I put in a Github issue for them to clarify.
If it is usable on online then the command to add the cartdidge would be like this command:
rhc cartridge add -a {your app name} http://reflector-getupcloud.getup.io/github/crunchyds/openshift-postgres-cartridge
You need to ensure that the official cartridges on OpenShift Online supports the version of PostgreSQL server. You don't necessary have to setup OpenShift Origin but might help you test your cartridges before using online.
Multiple error messages reference a wrong working directory:
tar: /versions/postgresql94.tar.gz: Cannot open: No such file or directory tar (child):
/env/PGPORT: No such file or directory
/env/PGDATA: No such file or directory
/env/OPENSHIFT_POSTGRESQL94_PATH_ELEMENT
/env/OPENSHIFT_POSTGRESQL94_LD_LIBRARY_PATH_ELEMENT
/env/OPENSHIFT_POSTGRESQL94_PATH_ELEMENT: No such file or directory
Your $OPENSHIFT_PG_DIR seems to be "/" which looks wrong. According to the documentation this variable is built from the shortname in the manifest: OPENSHIFT_{Cartridge-Short-Name}_DIR . Have you changed the short name in the manifest file?
We are using cdb (command line version of winDBG) to resolve a cab.
For getting the output in a file we are using the -logo output to specify the output file.
For a certain cab we are getting "CvRegToMachine(x86) conversion failure for 0x7536" more than a million times.
Basically we get a huge resolved code log, nearly 1GB, and all of it filled with the above string on each line.
We are using the following cdb command
cdb -z "abc.cab" -y "SymbolsPath" -G -logo "outputfile" -lines -c ".kframes 100;!analyze -v;!load msec.dll;!exploitable -v;vertarget;lmv;q"
Does anyone have any clue about what could be wrong here?
you cannot use -c and -G at the same time -c needs the first break to read the initial
command and act upon it if you need to run the code use g; at the end of -c commands
also many times -c commands need to be provided first and the debugee needs
to be at the end of commandline
cdb -c "<some cmd;someother cmd;g>" -z foo.cab
.load not !load should be used to load third party extensions
the string emitted "CvReg.........." seems to be related to Either SYMFLAG_NULL or SYMFLAG_REGISTER in the Flags member of SYMBOLINFO Struct .
a sample trial didnt cross that code path in my machine so either the corrupt dmp or more information regarding the dmp file may be needed to find the reason for the spew
creating dump
C:\>dir /b *.cab
File Not Found
C:\>cdb -c ".dump /ma /b foo.cab;q" calc | grep -i -E "dmp|dump|wr"
0:000> cdb: Reading initial command '.dump /ma /b foo.cab;q'
Creating C:\DOCUME~1\Admin\LOCALS~1\Temp\foo.cab.dmp - mini user dump
Dump successfully written
Adding C:\DOCUME~1\Admin\LOCALS~1\Temp\foo.cab.dmp - added
Wrote foo.cab
C:\>dir /b *.cab
foo.cab
**loading dump as debugees(cdb) debuggee (foo.cab) and looking around **
C:\>cdb cdb -z foo.cab
0:000> s -u dbgeng l?39b000 "CvReg"
020341f8 0043 0076 0052 0065 0067 0054 006f 004d C.v.R.e.g.T.o.M.
0:000> # *(*20341f8 dbgeng l?39b000
dbgeng!MachineInfo::CvRegToMachine+0xfe:
021bf8ae 68f8410302 push offset dbgeng!`string' (020341f8)
0:000> # call*dbgeng!MachineInfo::CvRegToMachine dbgeng l?39b000
dbgeng!ImageInfo::CvRegToMachine+0x22:
021b62f2 e8b9940000 call dbgeng!MachineInfo::CvRegToMachine (021bf7b0)
0:000> # call*CvRegToMachine dbgeng l?39b000
dbgeng!ImageInfo::CvRegToMachine+0x22:
021b62f2 e8b9940000 call dbgeng!MachineInfo::CvRegToMachine (021bf7b0)
dbgeng!TypeInfoValueFromSymInfo+0x4b:
022541ab e82021f6ff call dbgeng!ImageInfo::CvRegToMachine (021b62d0)
dbgeng!TypedData::SetToSymbol+0x25f:
02285edf e8ec03f3ff call dbgeng!ImageInfo::CvRegToMachine (021b62d0)
dbgeng!TypedData::SetToSymbol+0x2da:
02285f5a e87103f3ff call dbgeng!ImageInfo::CvRegToMachine (021b62d0)
0:000> ln 0x21bf8ae
(021bf7b0) dbgeng!MachineInfo::CvRegToMachine+0xfe | (021bf8d0) dbgeng!Ma
chineInfo::GetContextState
doing and uf on this function yields the check where SymbolInfo->Flags is
checked and decided my sample dump above doesnt enter the path