Sunday, December 27, 2020

power shell script to export only some columns from csv file

 


This power shell script goes through the csv file and exports the column into a filename+out.csv



 Get-ChildItem -Path . -Recurse -Filter '*.csv' |

   ForEach{

   $out  = $PSItem.Name+"_out.csv"

       $PSItem |

       Select-Object -Property FullName,

       @{Name = 'FirstLineOfFile';Expression = {Get-Content -Path $PSItem.FullName -First 1}}

   Import-Csv $PSItem.FullName   | select Phone,HomePhone,Home_Phone,Phone_1,'Phone Home',PhoneNumber,HomePhoneNumber,'Phone Number'| Export-Csv -Path $out -NoTypeInformation

   }



Power shell script Save the csv headers from the file


-Recurse recurses through folders.. and   write to Out_Headers.txt 


 Get-ChildItem -Path . -Recurse -Filter '*.csv' |

ForEach{

     $PSItem |

     Select-Object -Property FullName,

     @{Name = 'FirstLineOfFile';Expression = {Get-Content -Path $PSItem.FullName -First 1}}

 } |Out-File Out_Headers.txt -Append


Monday, September 14, 2020

Restarting apache2 (via systemctl): apache2.serviceJob for apache2.service failed because the control process exited with error code.

 



sudo /etc/init.d/apache2 restart    not starting



There is some syntax error in the file apache2.conf.

In a terminal, type:

cd /etc/apache2

Then:

apache2ctl configtest

Cannot load modules/mod_rewrite.so into server: /etc/apache2/modules/mod_rewrite.so: cannot open shared object file: No such file or directory


Enabling mod_rewrite

Now, we need to activate mod_rewrite.

  • sudo a2enmod rewrite

This will activate the module or alert you that the module is already in effect. To put these changes into effect, restart Apache.

  • sudo service apache2 restart


for 

LoadModule vhost_alias_module /usr/lib/apache2/modules/mod_vhost_alias.so
sudo a2enmod vhost_alias

Where is httpd.conf?

 

Ubuntu and debian   

/etc/apache2/apache2.conf

Centos and redhat

/etc/httpd/conf/httpd.conf

Monday, September 7, 2020

 

Creating a new user on ubuntu


sudo adduser <username>



to add this user to group


sudo addsuer <username> sudo