Skip to main content

Posts

Showing posts from 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 tho...

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...

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"  strF...

Hide the taskbar in Windows 10

Windows 10 update changes the way how to hide the taskbar. The old way was the traditional way of hiding the taskbar just like in Windows XP, by right clicking on an empty taskbar and selecting “properties” and from the properties window there is an option to hide the taskbar automatically. However, Windows 10 OSes that has  been updated, right clicking the empty taskbar does not show “properties” anymore.  Instead of clicking or finding properties, click on “settings” and on the settings Window, an option to hide the taskbar in desktop mode can be enabled or disabled. See screens shot below, on how to do it: ================================ Free Android Apps: Click on  links  below to find out more: Linux Android  App cheat sheet: https://play.google.com/store/apps/details?id=com.LinuxMobileKit Multiplication Table for early learners https://play.google.com/store/apps/details?id=com.TableMult...

Insert a new PCIe graphic card

Inserting a new PCIe graphic card to a custom built-PC, it sounds easy right. Plug the PCIe graphic card to the PCIe slot on the motherboard; insert DVI, VGA cable or any other input that the graphic card supports. Then, simply power on the PC and boom, everything will be working. However, the monitor shows a blank screen only . If the PCIe graphic card has been tested and working well, then try resetting the CMOS or remove the CMOS battery and power on the PC for 5 seconds turn it off and put back the CMOS battery. Now, turn on again the PC plug the monitor cable to the graphic card and if the PCIe card is inserted properly in the slot. Then the monitor will work as per normal. The display will be working fine. If the above process does not work and you are sure that everything is done properly then it could be some other issues. When inserting or troubleshooting the graphic card, it is better to unplug the hard disk. Because if the monitor has no display, you...

Windows 7 black screen after windows logo

Windows 7 just show a black screen, after showing the windows logo on startup. On Windows startup with the black screen, try pressing caps lock key. If caps lock key respond normally, then there’s a chance that windows boot up properly. Press the power button for 3 seconds and release it. If windows shutdown properly, turn on the computer again. This time, try pressing F8 to go to safe mode. In safe mode, open device manager. Open windows explorer, right click on “This Computer” or “My Computer” and select properties, this will open device manager.  Or alternatively, go to control panel and select device manager. In Device Manager, select the Display Adapter, right click on it and click properties. From the properties, uninstall the driver. Don’t worry windows will install its standard or default display driver. Restart or shutdown the computer, if the problem is just the corrupted display driver then startup should be working  fine and the black screen iss...

Copy folder/file to multiple folders

Copy a single folder to multiple folders? Copy a file to multiple folders? This can be done easily using PowerShell script. Script below requires PS 3.0, but it can easily be tweak for other version. Here's the script: #++++++++++++++++++++++++++++++ $source_folder="D:\xfolder\United Folders" dir -Directory "D:\Unity\Project_016\" | ForEach-Object { write-host $_.fullname Copy-Item -Path $source_folder -Destination $_.FullName } #++++++++++++++++++++++++++++++ What the script does is the $source_folder is to be copied to all folders in the destination. Basically, the "United Folders" is to be copied to the root of the sub folder in destination folder which is "D:\Unity\Project_016\". Example: D:\Unity\Project_016\01 D:\Unity\Project_016\02 D:\Unity\Project_016\03 After executing the script, the folders will look like this: D:\Unity\Project_016\01\United Folders D:\Unity\Project_016\02\United Folders D:\Unity\Project...

Excel formula fixed cell address

How to insert a formula with a fixed cell address? Absolute referencing will come to the rescue. Absolute reference in Excel is prefix with a dollar ($) sign. $A$1: This means that Column "A" and Row "1" will not change when copied to another cell. Example:       =SUM(A$1,$A2,$A$1) The above formula when copied from one cell to another cell, $A$1 will remain the same. While A$1,$A2 will change its location when copied to another cell.  A$1: This means that column "A" will change while row location (which is number 1) will not change when copied.  So this absolute reference will change like D$1, G$1 or E$1 depends on the location. So number "1" value will never change.  $A1: The column "A" will not change when copied from one cell to another cell, while the row value which is number "1" will change. So the above absolute reference will change like $A3, $A10, $A12 etc., Column "A" will be const...

Hide files in Linux

To easily hide files in Linux prepend the file or directory with a dot "." before its filename or directory name. To view hidden files in Linux use ls -la command. Hidden files in Linux are prepended with "." (dot). To hide a file, use the mv (move) command. mv command will rename the file or directory, if another path is specified aside from the current directory then the file is moved and at the same time it will be renamed, if a new file name is specified. Here's one example: mv hide_salary.txt .hide_salary.txt hide_salary.txt will be renamed to .hide_salary.txt Hiding files does not mean restricting access. It will only hide the file from the user. Proper permissions settings should be defined if restriction is needed. ls -l command will not show hidden files. ls -la command will show hidden files. To unhide the file simply remove the "dot". Unhide a hidden file: mv .hide_salary.txt show_salary.txt ...

Linux protect file from deletion

To protect file from deletion in Linux system, the chattr command is able to set the attributes that protects the file. chattr +a my_protected_file.txt chattr +a  == means that the file can be appended and the file can't be deleted as well. To set the file to immutable, "+i"  attribute can be used. chattr +i the_protected_file.txt Immutable file is protected from deletion and the original contents of the file is also preserved because no changes can be made. This command below: ls xx*.txt >> the_protected_file.txt The command above will show "permission denied" if the file is immutable. If the file is set with +a, then the above command will append the output of "ls" to the file. To unset or removed the attribute use the minus sign, "-a", "-i". For example, chattr -a the_protected_file.txt or  chattr -i the_protected_file.txt To know more about chattr type the command below: man chattr chattr --help...

Folder redirection very slow

Folder redirection is good and bad, well if everything is working as expected then it's definitely good and sometimes it's bad if it causes some unexpected issues such as very slow login. So you have a folder redirection working  smoothly over the years, users can always change their password whenever they want it and of course, System Administrator can also change user password anytime whenever they want it or whenever they just felt like changing it (just kidding), or when situations demand it. If folder redirection suddenly becomes problematic or causes some issue such as slow login, one issue could be that the user changes the password or the Sys Ad change the user password. One issue I encountered if the folder redirection suddenly becomes slow, if the client or the user has a mapped drive that is set manually and set to persistent, persistent mapped drives uses the Vault Credential Manager to store the password. If the password is not updated in the vau...

Map drive not working

Mapping drive can be set in different ways,  via group policy, using scripting (PowerShell, Vbscript, Jscript) or it can be set via command line. Setting script via command line can be done easily using ”net” command, like the example below. The example below shows the syntax on how to map a drive or folder. net use ? The syntax of this command is: NET USE [devicename | *] [\\computername\sharename[\volume] [password | *]]         [/USER:[domainname\]username]         [/USER:[dotted domain name\]username]         [/USER:[username@dotted domain name]         [/SMARTCARD]         [/SAVECRED]         [[/DELETE] | [/PERSISTENT:{YES | NO}]] NET USE {devicename | *} [password | *] /HOME NET USE [/PERSISTENT:{YES | NO}] Example: N...