Skip to main content

Posts

Showing posts from December, 2016

Linux bash script copy folders and files from list

In Linux special characters such as "#", "-" and other special characters cannot be access directly either by manual copy or via script. For example this path below it has the sharp "#" key:
/usr/dfiles/$line/Tasks/#msgs/
cp "/usr/dfiles/$line/Tasks/#msgs/*.eml" "/mnt/NAS/Tasks1/line/"
Even though the path is enclosed by quotation marks, Linux system will show "No such file or directory".

Since the system is unable to find the "#msgs" directory.

As a work around in this issue is to append "--" double dash before the cp command and everything will work fine.

So, this command below will work.

cp  -- "/usr/dfiles/$line/Tasks/#msgs/*.eml" "/mnt/NAS/Tasks1/line/"
Copying one folder is quite practical to do it by hand rather by script.
But if you are copying hundreds or thousands of folders, doing it manually is quite painful.
To copy hundreds or thousands of folders to another folder the pra…

Create a progress bar in Excel

Create a progress bar in Excel that varies on the input value and range.

If the value is  equivalent to 100% or maximum input is reach then the color will fill the whole cell.

This example below was created using Excel 2010, the logic should be the same with other version that supports this function.

1. Select the cell, that will have the progress bar.
    Click on "Home" tab, click on "Conditional Formatting"
    - In drop down menu select Data Bars
       - In the sub menu click "More Rules".

See screen shot below:



2. After clicking "More Rules", "New Formatting Rules" window will open.
    - In "Select a Rule Type"
       "Format all cells based on their values" should be selected
    - Under Rule Description
       Set the type to "number"
       Set the range of minimum and maximum value
       Select the color that you want and click "OK", once customization is done.

See screen shot below:





Vbscript send email via Office 365

Sending automated email via Office 365 account requires the use of SSL or in some instances you need to use SSL and TLS both enabled on the script.

Below is an example that works fine using Vbscript.

This is useful if you need to automate email messages via Task Scheduler or Windows event attached to this script, when the event is triggered the script will execute the VBS file and send the message.

Modify the message subject, body and of course, the email domain name, user and password.

Open notepad copy and paste the code, save as "filename.vbs"

The quotes are important when doing save as via notepad or else the file will be save as .txt.

Enjoy! Cheers!

'=======================
Dim xstrAll(), strMessage,intupper()

Set objFSO = CreateObject("Scripting.FileSystemObject")

'Send the mail
SentMail


Sub SentMail

strMessage =  strMessage & "Your other message..."

strTo= "your.office365@domain_account.com" 
strFrom="your.office365@domain_accou…