Improve company productivity with a Business Account.Sign Up

x

Shell ScriptingSponsored by Flatiron School

10K

Solutions

6K

Contributors

The term 'shell' refers to a general class of text-based command interpreters most often associated with the UNIX and Linux operating systems. Popular shells include Bourne, Debian Almquist (dash), Korn (ksh), Bourne Again (bash) and the C shell family (csh). Some view the DOS 'cmd' prompt as a minimal shell of sorts. It is also possible to install Cygwin on Windows and emulate a full Unix environment with complete shell capabilities. Terminal emulators, such as xterm, GNOME Terminal and OS X Terminal, can be used to access shell.

Share tech news, updates, or what's on your mind.

Sign up to Post

Need help creating a GPO, linking it to the domain, and setting policies

Hello

We are an MSP and have about 20 client locations that we manage and would like to create a Powershell script to create and configure a Audit / Account / Password policy for all of our clients using the following settings:

[Unicode]
Unicode=yes
[Version]
signature="$CHICAGO$"
Revision=1
[Event Audit]
AuditPolicyChange = 1
AuditAccountManage = 3
AuditAccountLogon = 3
[System Access]
MinimumPasswordAge = 0
MaximumPasswordAge = 90
MinimumPasswordLength = 8
PasswordComplexity = 1
PasswordHistorySize = 10
LockoutBadCount = 5
ResetLockoutCount = 15
LockoutDuration = 15
ClearTextPassword = 0
[Registry Values]

I have searched as best as I could for how to implement this but have not been able to find anything.

Any help with this would be great.

I have also attached a screen shot of the report as well.
Audit-Password-Account_Policy_Report.jpg
0
Free Tool: SSL Checker
LVL 12
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Red Hat v4:

I need an article / link, etc. to set up to email log files for root to an external email and set up relay to that external email.
0
I have a challenge related to updating a RedHat server.

On this server several packages need NOT to be updated because of application dependencies.

For this reason when I update the server I do something along the line of:
1) Check if any available patch can be seen, if so save result to file: sudo yum check-update | awk '(NR >=4) {print $1;}' > /tmp/update_packages
2) Then I remove the "blacklisted" packages from /tmp/update_packages
3) Run yum update against the obtained file

While this procedure is ok what can happen if one of the update packages has one of the blacklisted ones as dependency is that also the blacklisted one will be updated, right?

Is there any other procedure that you can suggest for this kind of scenario?

Thanks for your time and help.
0
Hi experts

I am looking for a script that will pull out  storage usage
Which is above 80% .



Thanks in advance
0
im looking for a script,

I have a folder, which needs to be copied 100+ servers, and in that a folder I have bat file needs to be executed and it will generate CSV file.
and again all the CSV files needs to be copied back to source.

All servers are in workgroup, not in a domain, uses the same password and user id.

environment windows 2008 r2 std and enterprise

Appreciate your help.. Thanks
0
Hi all,
I have a zonelist.txt file

In the file the contents are standard forward and reverse zones.  For example

db.test.com
db.sark.hello.com
db.177.6.206.in-addr.arpa

I would like a bash or a shell script that uses dig to transfer each of the contents into individual files based on the zone and put them into a folder called transfer.

For example if I do a list in that folder I would have individual flies. For example

db.test.com
db.sark.hello.com
db.177.6.206.in-addr.arpa

I use a Mac and I thought I could use
dig @100.100.100.100 -f zonelist.txt

But that just shows them on screen and not in individual files.

Lastly. Is any zone transfer is refused or failes and or for any reason it does not get that zone to make a file called errors.txt
0
How can I get a list of packages available for update on RedHat (using yum) and put the package list in a file for later use?

Basically I would like to be able to remove from the list a few names with a BASH script and then perform a yum update using the updated list.
0
I have some questions about RHUI (I just have the acronym and I know that is related to Operating System updates):

  • What is RHUI?
  • How can I check with a BASH script if it is working?
  • How can I check with a BASH script if there are any available patches?

Thanks for your time and input.
0
My input format is log1.txt .which contains below information.

Input Count :982307
Error Count :3
Historical Count :845555
Output Count : 95071
Run Started At : Tue Apr 10 09:25:32 EDT 2018
Run Ended At : Tue Apr 10 09:47:58 EDT 2018
Total Records Read: 95071
Total Records Added: 477
Total Records Skipped: 94547
Total Records w/error: 47

==============================
Output format should be below format and send email



0
Robocopy

Can someone please give me a script that allows me to robocopy a lot of directories from a source to a destination while referencing the directory names listed in a text file
The list will be in c:\scripts
0
Free Tool: IP Lookup
LVL 12
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Hi,

   We get some postgres db command files (Insert, Update, Create, Drop etc) with the DB commands in them on a location(\usr\DB Scripts) in our Linux environment.
We need to come up with a script, which when ran,
   -> creates a consolidated file, with the statements in each file, ended with a GO statement
   -> Move the individual files used in the above consolidated file, into an archive directory, with timestamp in the name.
   -> Leave any unused files in the original location (\usr\DB Scripts); These will be the files which may have been added just after the script was run
   -> Run another script which compiles the consolidated file, against the database.

Can someone kindly help with this? I'm fairly new to the linux world.
0
Hello Everyone:)

I need a list of mailboxes on my Exchange server that includes:

- DisplayName
- Alias
- Primary SMPT-Address
- Premissions = This is actually the most important part of the evaluation I need

I should also be able to export this to CSV.

Any ideas how to do this in Powershell?
0
need some help here.. when I run the command, the message get truncated, it does not shows complete message in export csv file.. what am I missing here ?

Get-EventLog -LogName application  -after "4/8/18 3:00:00" -before "4/8/18 08:45:00"| ? {$_.eventid -match "9523" } | select -Property Source,time*,Machinename,message | export-csv C:\temp\NADB15.csv -notypeinformation
0
Hi Experts,

I need your help to create a shell script.

Below requirement lines may have repeated lines, please excuse me for that. It may be because I have tried to explain what ever first came in my mind.

Requirement is:

Search for data using parent ID from old.log log files which has sequence appended to it as suffix when it gets created.
Each old.log gets created with incremental sequence number after a perticular size has been reached like a log rotate.
I have to search through each old.log file for some data and capture it in Oracle database.

For example, lot of lines will have parent ID and same parent ID can also occur in next old.log sequenced file with an incremental suffix.
Once I searched for parent ID in a file and collected all it's data, I have to parse that data and insert in database.
Parsing meaning, I have to capture few field data like CHILDId, StartTime, FinishTime etc.

The challenge is, parent ID can be in next file too with it's relevant data so I have to search for parent ID in many files.
Data could be scattered all over log files, mostly once parent ID started the same parent ID would be in next log file and not in old log files. If parent ID started in old.log.12111 file then it can continue in next old.log.12112 log file.
old.log files be created every few minutes so script will have to remember which files it searched and skip them next time search.
I do not want to search through same log file next time, but I have to …
0
Currently writing a management menu interface for managing printers on our HP UX system.

Scripts are written in Korn Shell.

The following command
lpstat -pTERRYTST

Open in new window

returns the following:-

printer TERRYTST disabled since Apr 10 08:36 -
        new printer
        fence priority : 0

Open in new window


I need to be able to search the response for keywords to identify states.

So I need to fill a variable with 1 if the printer is disabled, another variable with 1 if its new.

No idea how to complete this in Korn Shell scripting as am very new to the language.

Help! :)
0
I am looking for some information online as to how to script using Windows PowerShell.  I am not a programmer and do not understand the syntax as to where all the symbols need to go in order to make scripts run correctly.  I need info that explains exactly how to do this as if you do not have programming experience.
0
Duplicity Linux Backup to Azure

Hi All,

Can anyone help me with the error below please? When executing the following command, I receive the corresponding error.

duplicity --full-if-older-than 1M /srv/folder azure://container --archive-dir /var/lib/folder --volsize 2000 --tempdir /srv/tmp

Open in new window


Import of duplicity.backends.giobackend Failed: No module named gio
UnsupportedBackendScheme: scheme not supported in url: azure://container

Open in new window


Running on a updated Debian build with Azure CLI 2.0
0
I have a file with 10000 values. I need to search for these values on a Server folder and once found, need to copy the
file to another folder. The values to search for are in one column in a spreadsheet. Values attached. They are PDF's.

How can I accomplish this?
Book1.xlsx
0
A folder having tons of duplicate *.msg files for example these 4 files (attachment1) now we want only one file to be kept in the folder after deletion of duplicate ones based on there LastWriteTime and length using powershell.
already tried this but it deleting all files in the folder which is obviously not required.
gci -Path D:\test\*.msg -file -recurse | Group-Object -Property TimeWritten | Where-Object { $_.Count -gt 1 } | select -ExpandProperty group | foreach {get-filehash -LiteralPath $_.fullname} | group -property TimeWritten | where { $_.count -gt 1 } | foreach { $_.group | select -skip 0 } | select -ExpandProperty path | foreach {Remove-Item -LiteralPath $_ -WhatIf}

Open in new window

Result.. (attachment2)
Thank you in advance..
0
The 14th Annual Expert Award Winners
LVL 7
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

I want to compare crontabs on 6 servers in centos 7 using shell script. Please help me. Thanks in advance
0
I'm trying to call mattermost "platform" application from a python script to create users & teams from a CSV file but i'm having an issue with the subprocess.call command which doesn't seems to recognize any parameter passed after --name.  I'm new to python so i won't be offended if you point me the obvious.

my CSV files got columns group, group_display, email, password.

with open("./accounts.csv", "rb") as wFile:
    os.chdir("/opt/mattermost/bin")
    wReader = csv.DictReader(wFile)
    for wLine in wReader:
        wCommand = []
        wCommand.append('./platform')
        wCommand.append('team')
        wCommand.append('create')
        wCommand.append('--name ' + wLine['group'])
        wCommand.append('--display_name \"' + wLine['group_display'] + '\"')
        wCommand.append('--private')
        print wCommand
        wRet = subprocess.call(wCommand)
        if (wRet == 0):
                print 'Imported ' + wLine['email']
        else:
                print 'Error importing ' + wLine['email']

Open in new window


i'm getting the error:

Error: unknown flag: --name mycustomername
Usage: platform team create [flags]


If i run the command from the cmd line with this command, it will pass:
./platform team create --name mycustomername --display_name "The Full Customer Name" --private

Any idea what i'm missing?
0
I would like a script to go through a directory of images and make folders and move images into that folder based on lines in a csv file.

For example:

The csv file would have column names like FolderName, Image1, Image 2, Image3, Image4

FolderName = 18-001
Image1 = 18-001.jpg
Image2 - 18-002.jpg
Image 3 = 18-003.jpg
Image 4 = personsname.jpg

So based on that wtihin the folder where the .csv file would be located and all of these images would be located I want to make a folder named "18-001" and then move Image1-4 into that folder.

With one catch.  I might sometimes have more than 4 images.  Each csv file might have different images.  So a "while" statement would be needed to read the .csv Image columns - they do all start with "Image"
0
How can I script:

Install all PKG in /foldername

Maybe write log somewhere too....

Thanks
0
Experts Could use some scripting assistance

function Get-ActivationStatus {
    [CmdletBinding()]
    param(
        [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
        [string]$DNSHostName = $Env:COMPUTERNAME
    )
    process {
        try {
            $wpa = Get-WmiObject SoftwareLicensingProduct -ComputerName $DNSHostName `
                -Filter "ApplicationID = '55c92734-d682-4d71-983e-d6ec3f16059f'" `
                -Property LicenseStatus -ErrorAction Stop
        }
        catch {
            $status = New-Object ComponentModel.Win32Exception ($_.Exception.ErrorCode)
            $wpa = $null    
        }
        $out = New-Object psobject -Property @{
            ComputerName = $DNSHostName;
            Status       = [string]::Empty;
        }
        if ($wpa) {
            :outer foreach ($item in $wpa) {
                switch ($item.LicenseStatus) {
                    0 {$out.Status = "Unlicensed"}
                    1 {$out.Status = "Licensed"; break outer}
                    2 {$out.Status = "Out-Of-Box Grace Period"; break outer}
                    3 {$out.Status = "Out-Of-Tolerance Grace Period"; break outer}
                    4 {$out.Status = "Non-Genuine Grace Period"; break outer}
                    5 {$out.Status = "Notification"; break outer}
                    6 {$out.Status = "Extended Grace"; break outer}
                    default {$out.Status = "Unknown value"}
                }
            

Open in new window

0
I'd like to add a shortcut on my desktop that I can just double click to be able to launch "shell:startup" as per the suggestion in this Microsoft Article which says in part;

To add or remove an app from the Startup tab, press the Windows Logo Key  + R, type shell:startup, and then select OK. This opens the Startup folder.

I've tried creating a batch file to do the above, but it doesn't work for me... I just notice a DOS windows pop up for a second and then it disappears.

Can anyone show me how I can create an icon to be able to do this?

My system is a Windows 10 Professional install.

Many thanks...

Andrew
0

Shell ScriptingSponsored by Flatiron School

10K

Solutions

6K

Contributors

The term 'shell' refers to a general class of text-based command interpreters most often associated with the UNIX and Linux operating systems. Popular shells include Bourne, Debian Almquist (dash), Korn (ksh), Bourne Again (bash) and the C shell family (csh). Some view the DOS 'cmd' prompt as a minimal shell of sorts. It is also possible to install Cygwin on Windows and emulate a full Unix environment with complete shell capabilities. Terminal emulators, such as xterm, GNOME Terminal and OS X Terminal, can be used to access shell.