Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Sunday, 23 July 2017

Count number of characters in file from command line and Vim

Count number of characters in file from command line and Vim


The command wc prints several file statistics: bytes, lines, words, etc. Using the -m option we can count the number of characters in a text file.

Install

Open a terminal window and run:

wc -m FILE

We can count the number of characters from Vim editor using this ex command:

:!wc -m %

References

wc(1) - Linux man page
{ Read More }


Saturday, 3 June 2017

Create a file from varius files using win command

Create a file from varius files using win command


Let you have two separate file such as "A.avi "and "B.avi". Now you want to create a file C.avi that contain all of content of file A.avi and B.avi. In generally for this you have to want to use software but you can do this by windows command.

Process:
1. Open command prompt by "windows+r" write "cmd" and press enter.
2. Go to the drive where files having A.avi and B.avi by "cd D:" (D is the drive).
3. Write command "copy<space>/b<space>A.avi+B.avi<space>C.avi" and press enter.
4. Wait sometime until showing " 1 file(s) copied."


NB: In image my files was in F drives Download folder, and 3.avi creating from 1.avi and 2.avi.
Now you can see the C.avi is the compact file to A.avi and B.avi. By this process you can create all type of video files to one compact file.
{ Read More }


Thursday, 25 May 2017

Create Bootable Linux ISO from DD command

Create Bootable Linux ISO from DD command



I have tried many times to create a Bootable USB linux from ISO but failed almost 20 times. After a lot of googling I have found as this is the proper command

dd if=/path/to/ISO.iso of=/dev/sda bs=4M;sync

Thats it. Note: at of=/dev/sda dont give anything after your device. for example If your USB mounted as /dev/sdb1 then at of you should give as of=/dev/sdb only.
{ Read More }


Tuesday, 16 May 2017

Creating an Evolution e mail from the command line and python

Creating an Evolution e mail from the command line and python


Evolution is intended as a GUI e-mail client, so the scripting options are limited. Also, it looks like you cannot autosend e-mail from a script, theres so script command equivalent to the send button.


But thats a good thing; I can autosend from nail when I want to. So a script will compose the e-mail, which will sit on my desktop until I review it and click to send it. Nice.


shell command source

This command creates a window with To:, From:, Subject:, and Body filled in. From: is already known by Evolution, the rest is parsed from the following command:

evolution mailto:person@example.com?subject=Test&body=Some%20crazy%20story%20stuff%0D%0Acolumn1%09%09column2%09%09column3%0D%0A%0D%0ASincerely,%0D%0A%0D%0AMe


Another (easier) way:
evolution mailto:person@example.com?cc="second_person@example.com"&subject="This Is The Subject"&body="This is the body of the message"&attach=Desktop/test_file.xml
  • evolution mailto:person@example.com - Launches Evolutions e-mail composer and To: line
  • ?cc="Person@example.com" - CC: Line
  • &subject="Subject" or ?subject="Subject" - Subject line
  • &body="Body" - Body of the e-mail is everything after this line
  • &attach=/path/file - Files to attach
  • %20 - Space
  • %0D%0A - CR/LF (new line)
  • %09 - Tab

python command

Python 2.x has its own smtp module for creating e-mail, its far more useful in most circumstances. But in this case, we want the composed evolution window.

import os
body_string = This is the body of the e-mail message
body_string = body_string.replace( ,%20)
os.popen(evolution mailto:person@example.com?subject=Test&body= + body_string)
  • import os - Use pythons os module
  • body_string = This is the body of the e-mail message - The body in normal text
  • body_string = body_string.replace( ,%20) - Encode the spaces (evolution will decode them). Tabs, newlines, and other reserved strings need to be encoded.
  • os.popen(evolution mailto:person@example.com?subject=Test&body= + body_string) - The os.popen(cmd) executes shell cmd. Note that cmd is just a python string, and you can use all the string tools on it, like adding body_string.
>>> import os
>>> to = person@example.com
>>> cc = "second_person@example.com"
>>> subject = "This is the subject"
>>> body = "This is the body"
>>> attachment = Desktop/rss_test.xml
>>> os.popen(evolution mailto:+to+?cc=+cc+&subject=+subject+&body=+body+&attachment=+attachment)
{ Read More }


Wednesday, 26 April 2017

Create OS X NetInstall Images from Command Line

Create OS X NetInstall Images from Command Line


Creating NetInstall images on OS X is quite easy, there are a number of different ways to do so. There are tools such as AutoNBI, or Casper NetInstall Creator. But third party tools are not required to make the NBI for Mavericks, Yosemite, or El Capitan. The System Image Utility is a great tool with a GUI to make the images. The only caveat to this that I have found is that you can only create an image from the installer of that version you are on. So lets say you have a MacBook Pro running Yosemite and you have the Install application for Mavericks in your applications folder. When opening the System Image Utility, it would not recognize the installer.

One way to go around this is to use the imagetool through the command line. This is a Unix Executable File located in the Contents folder of the System Image Utility.

/System/Library/CoreServices/Applications/System Image Utility.app/Contents/MacOS/imagetool

From Terminal, this can be run to create a NetInstall Image with the install application that was downloaded from the App Store and no other tools are required. To create a Mavericks NetInstall, I have copied the Install OS X Mavericks.app outside of the Applications folder for safe keeping, but in order to run the tool the installer must be in the Applications folder. Open up terminal and run this command (note, you must be sudo to run):

sudo /System/Library/CoreServices/Applications/System Image Utility.app/Contents/MacOS/imagetool --netinstall --index 1001 --source /Applications/Install OS X Mavericks.app --destination /Mavericks/NetInstall of Mavericks OS X --name Mavericks NetInstall

The same can be done with Yosemite on the same MacBook Pro mentioned earlier.

sudo /System/Library/CoreServices/Applications/System Image Utility.app/Contents/MacOS/imagetool --netinstall --index 1002 --source /Applications/Install OS X Yosemite.app --destination /Yosemite/NetInstall of Yosemite OS X --name Yosemite NetInstall

In order to create the NetInstall image for El Capitan, the machine MUST be running El Capitan. Otherwise, image tool will throw an error and will not complete. However, on an El Capitan machine the command is the same and you can create all three versions from there.

sudo /System/Library/CoreServices/Applications/System Image Utility.app/Contents/MacOS/imagetool --netinstall --index 1003 --source /Applications/Install OS X El Capitan.app --destination /El Capitan/NetInstall of El Capitan OS X --name El Capitan NetInstall

The only version of OS X where the imagetool command is different is in Mavericks, where the executable is located: 

/System/Library/CoreServices/System Image Utility.app/Contents/MacOS/imagetool
{ Read More }