[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Scripting Languages

27K

Solutions

20K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.

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

Sign up to Post

need an archival script that runs on a nighty basis

we maintain our logs for a given month in a directory

/a/b/c/2018-01/xyz-2018-01-01-1.log
/a/b/c/2018-01/xyz-2018-01-01-2.log
/a/b/c/2018-01/xyz-2018-01-01-3.log
/a/b/c/2018-01/xyz-2018-01-02-1.log
/a/b/c/2018-01/xyz-2018-01-01-2.log
.
.
.
/a/b/c/2018-02/xyz-2018-02-01-1.log
/a/b/c/2018-02/xyz-2018-02-01-2.log
.
.
.
/a/b/c/2018-02/xyz-2018-02-31-1.log
/a/b/c/2018-02/xyz-2018-02-31-2.log

on a nightly basis we have to copy logs to corresponding months folder with date and tar and gzip

if the directory does not exist for the month we have to create it when copy and tar the files,

ex : /a/b/c/archieve/`date +`'%Y-%m'`/`

we should be maintaining the archived files for the last 3 days and hould be removed older than 3 days
0
OWASP Proactive Controls
LVL 12
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

How can I modify this script so that it pulls the BCC emails from a file, a text file for instance?

SubjectDate = InputBox("Date to be added to the subject:", "Enter date")
MailTo = "email1@gmail.com"
From = "mainemail@someprovider.com"
Subject = "This is a test " & SubjectDate
Body = "Hi, This is an VBScript to send email, Regards, User."
Username = "mainemail@someprovider.com"
Password = "passwordhere"
BCC = "email2@gmail.com"

Email MailTo, BCC, From, Subject, Body, Username, Password

Sub Email (MailTo, BCC, From, Subject, Body, Username, Password)
 Set objMessage = CreateObject("CDO.Message")
 With objMessage
  .Subject = Subject
  .From = From
  .To = MailTo
  .BCC = BCC
  .TextBody = Body
 End With
 With objMessage.Configuration.Fields
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mail.com"
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mainemail@someprovider.com"
      .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "passwordhere"
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
      .Update
      End With
      Set

Open in new window

0
Is there a way to convert .xls to .csv?
if yes, how can this be done in an automated way?
0
My requirement is to convert below pipe delimited  text (input.txt) file into an excel file (.XLSX) using VBScript .
 
Here is example of my text input file :-

input.txt (attached for reference)

Name|age|gender|department|year

don|23|male|computer|2010
ptalakes|24|female|maths |2015
chang|28|male|arts |2016
prag|29|female|science |2018
tom|26|male|arts |2017
john|27|female|sports |2018
simon|22|male|arts |2018

Output file  (output.xlsx attached )  should be saved in excel file as below in corresponding cell :-


Name      age      gender      department      year
don      23      male      computer      2010
ptalakes      24      female      maths      2015
chang      28      male      arts      2016
prag      29      female      science      2018
tom      26      male      arts      2017
john      27      female      sports      2018
simon      22      male      arts      2018



Would appreciate if some one could please help me to get complete code in vbscript.

Thanks in advance
Praveen
Input.txt
output.xlsx
0
Hi Experts,

I want to complete this script I want to the script to connect to SFTP site and transfer files from D:\testfolder\*.*  to the remote directory /remotesftp/testfolder/*.* , can someone help

Below is the initial script

# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"

# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "xxxxxsftp.domain.com"
    UserName = "testsftp"
    Password = "tests5F7p"
    SshHostKeyFingerprint = "ssh-rsa 1024 fashghrhyjmukjfgvjhgfhjtr="
}

$sessionOptions.AddRawSettings("FSProtocol", "2")

$session = New-Object WinSCP.Session

try
{
    # Connect
    $session.Open($sessionOptions)

   
}
finally
{
    $session.Dispose()
}
1
Hello,

What is the best way to get computer's domain into a variable?
So for example, all our computers are joined to the target. So I want to query that value and record domain FQDN and Domain NB into  variables. Similar to what I found to do for username. However, I need to get the domain from computer and not user. Unfortunately, there is no such a variable for a computer only for the user. Please advise.

$domainDNS = $env:USERDNSDOMAIN (similar to this)
$domainNB = $env:USERDOMAIN  
[string] $SQLName=$env:computername
[string] $SQLFQDN = $SQLName + "." + $domainDNS
0
In Powershell, I would like to rename a file called "9.pdf" at C:\Attachment\Folder to the following date format October 16, 2018.pdf....

Only after the following script has run, with the purpose of inserting the new script at the end of this script if possible..  
And, I would like for it to pull the Date from the Date input which is found in the following script..


Get-ChildItem 'C:\Attachment\Folder' -Filter *.pdf | Where-Object {$_.BaseName -ne '9'} | Remove-Item -Force

Function Select-DateForm {
[CmdletBinding()]
Param(
	[String]$Title,
	[String]$Prompt,
	[DateTime]$MinDate,
	[DateTime]$MaxDate
)
	Function Show-FormMain {
		Add-Type -AssemblyName System.Drawing
		Add-Type -AssemblyName System.Windows.Forms
		[System.Windows.Forms.Application]::EnableVisualStyles()

		$formMain = New-Object -TypeName System.Windows.Forms.Form
		$formMain.ClientSize = New-Object -TypeName 'System.Drawing.Size' -ArgumentList 250, 250
		$formMain.FormBorderStyle = 'FixedSingle'
		$formMain.MaximizeBox = $false
		$formMain.MinimizeBox = $true
		$formMain.Text = If ($Title) {$Title} Else {'Date Selection'}
		
		$labelPrompt = New-Object -TypeName System.Windows.Forms.Label
		$labelPrompt.Location = New-Object -TypeName 'System.Drawing.Point' -ArgumentList 16, 8
		$labelPrompt.AutoSize = $true
		$labelPrompt.Text = If ($Prompt) {$Prompt} Else {'Please select a date:'}
		$formMain.Controls.Add($labelPrompt)

		$monthCalendar = New-Object -TypeName 

Open in new window

0
How to search pdf files for a key word like "Sticky" and report those pdf files with that key word. One example is attached.

Regards,

Dallag
CONCLUSIONS-AND-RESULTS.pdf
0
I need a powershell script that will do the following.

1.  I have a powershell command that will read the subkeys of a mail profile
Get-ChildItem -Path HKCU:\Software\Microsoft\Office\15.0\Outlook\Profiles

Open in new window


The output of the subkeys are below...

Name                                Property
----                                      --------
cool Outlook Profile
Outlook Profile
outlook



2.  I need each of the subkeys into a variable, how do I do that in Powershell?

3.  After I have that answer, I would like to run the command for each subkey variable, inst.exe /u /service dmol /p "Variable=mailprofile"

I really appreciate the feedback!
1
Hi Experts,

I have the following command running as a batch file (on task scheduler) in an hourly bases.
xcopy "C:\Users\bfuchs\Dropbox\Caspio\caspiotables.zip" f:\Conversion\Caspio\ /y

Open in new window


would like to have this running in another pc as well as a backup.

However would prefer to have the following modifications

1- To first check for date/time that file f:\Conversion\Caspio\caspiotables.zip when it was modified, if it was not within the hour then perform the task.
2- Get an email informing it was done (so i know the 1st one failed).

Thanks in advance.
0
Introduction to Web Design
LVL 12
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

I have a multi site AD domain
Because of the type of data we work with, most of our file servers are replicated from corp site to local site
I have GPP doing drive maps applied to each site OU and currently works great so long as the user only logs on at his site. So user at site 1 gets 3 drive mapping to the servers at his local site and the rest point back to servers at corp site. We now are implementing a VDI solution that will reside on servers at corp site and users from all sites will log into. The issue I am having is when a user from any site other than corp logs onto the vdi machine they are getting their drive mappings based on the OU their user account is in which in turn as by design maps their drives to the servers at the site their account resides in. Can any point me in a direction I can consolidate ALL my drive mappings into 1 script that will map the drives based on subnet?
Any help would be greatly appreciated
1
Using pdftk what command can I use to join files, first in the order of the file that was created first?

For example, let's say in the path C:\Attachment, there are 4 file all with different names, however all with different time stamps...

How can I modify this command so that it joins each file it finds but based on time stamp? all into 1 file?

pushd "C:\Users\Desktop\Folder"
pdftk ….. cat output C:\Attachment\OneFile.pdf
popd
0
I would like to change the following script so that whatever pdf file or files that it sees in C:\Attachment\..., that it will send that file, or files as an attachment.

###PROGRAM START###
	# Invokes the Send-MailMessage function to send notification email
	$splat = @{
		From =                  'email1@mail.com'
		To =                  Get-Content -Path ( Join-Path $PSScriptRoot 'List.txt')
		SmtpServer =      'snto,server,cin'
		Subject =            $subject
		body =                  $MessageBody
		BodyAsHtml =      $true
		Attachment =      ( Join-Path $PSScriptRoot '*.pdf' )
	}
	Send-MailMessage @splat
###PROGRAM END###

Open in new window

0
Hi,

I am working through the process of automating my backups in AWS. I have a process to take VSS snapshots of my volumes, and I also have a separate script in AWS Lambda which can automatically take an AMI. What i'm now looking to do is combine these in to one single function. The lambda script does take a snapshot, however I'm not certain that it's a VSS2 snapshot. I've googled the issue but all the articles I've come across seem to describe the two processes as separate entities.

This is the Python script I'm using in Lambda to take an AMI:

# Automated AMI Backups
#
# @author Robert Kozora <bobby@kozora.me>
#
# This script will search for all instances having a tag with "Backup" or "backup"
# on it. As soon as we have the instances list, we loop through each instance
# and create an AMI of it. Also, it will look for a "Retention" tag key which
# will be used as a retention policy number in days. If there is no tag with
# that name, it will use a 7 days default value for each AMI.
#
# After creating the AMI it creates a "DeleteOn" tag on the AMI indicating when
# it will be deleted using the Retention value and another Lambda function

import boto3
import collections
import datetime
import sys
import pprint

ec = boto3.client('ec2')
#image = ec.Image('id')

def lambda_handler(event, context):
   
    reservations = ec.describe_instances(
        Filters=[
            {'Name': 'tag-key', 'Values': ['backup', 'Backup']},
        ]…
0
what commands in vbs will move files out from one folder to another?
0
I am trying to display a custom message when a user closes or about to close a browser tab. In the earlier versions of the browsers I could do this using onunload or onbeforeunload events and display a pop-up message but the newer versions do not allow me to customize the message. Is there anyway I can display a customized message when the user closes the browser tab or when clicks on the close button of the browser tab? A tool-tip could also work when the user is hovering on the close button or clicks on the close button of the browser. Thank you for any help.
0
Greetings Everyone
I am very new and green at python scripting and need some guidance.
I have a script that reads temperature data from 3 different sensors.
It is set to currently print that data to the terminal screen.
The script works OK, but the issue I have is the data gets printed to the screen with an overabundance of decimal places. I have come across a function to round that data to 1 or 2 decimal places, which is what I want.
Unfortunately I can't seem to get the syntax correct and the function fails to work as I need.

Here are the print commands currently:

# Get Temperature and print to screen
while True:
    print ("Pool Temp = ", read_temp(temp_sensor_1))
    print("Air Temp = ", read_temp(temp_sensor_2))
    print("Box Temp = ", read_temp(temp_sensor_3))
    time.sleep(2)   # Read every 2 seconds

Open in new window


That returns the following output:

Pool Temp = 51.0166
Air Temp = 51.355
Box Temp = 64.557

Open in new window


Waits 2 seconds and repeats until I kill the script.

What I am looking for is something like this:

Pool Temp = 51.1°F
Air Temp = 51.2°F
Box Temp = 64..6°F

Open in new window


I found a reference to using the str.format() syntax but have not been able to make it work correctly.
Any help would be greatly appreciated.

:)

-Bob
0
What are the strings of commands in CUTEFTP to download all files found in a specific remote folder?
Either it can override all local files, or it should only download the latest files it finds which are not on the local folder.
0
I would like to modify this FTP script below so that it does the following

1. Download any new files to the local directory.  (So the script needs to determine what it downloaded last time, so that it doesn't download it again, unless it it's easier to write the script so as to download everything it sees in the remote directory to the local directory and just overwrite any files which it sees, which is ok as well, in this scenario).

2. Does not delete the previous files from the remote directory.


@echo off
setlocal 

set password=xxxxxxxxxx
set /p password=<%~nx0:password
if not "%password%"=="" goto OK
set /p password=Enter password: 
echo %password%>%~nx0:password
:OK

set localdir=\\server1\main\
set remotedir=/out
set ftpserver=xxxxx.xxxxxxxxxxx.com
set username=xxxxxxxx

::del "%localdir%\*.*" /q

call :GetFtpFiles
call :ClearFTPFiles

exit /b

:GetFTPFiles
    (echo open %ftpserver%
    echo user %username% %password%
    echo bin
    echo cd %remotedir%
    echo lcd "%localdir%"
    echo mget *.*
    echo quit
    ) | ftp -n -i
    exit /b

:ClearfTPFiles
    (echo open %ftpserver%
    echo user %username% %password%
    echo cd %remotedir%
    (for /f "tokens=*" %%a in ('dir /b /a-d "%localdir%\*.*"') do @echo dele "%%~a")
    echo quit
    ) | ftp -n -i -d

Open in new window

0
Learn SQL Server Core 2016
LVL 12
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

is there any method to get a list of AD users who are using weak passwords for windows 2012R2 domain.
0
Combine all .csv files into one file,
Input folder is C:\Temp1\Folder..
Output folder will be the same.
Thanks in advance.

Batch is preferred, otherwise poewrshell would be fine as well.
0
I would like to use a simple script  to delete all *.csv files found in C:\Temp1\...  except for one file called Output.csv

It would be in Batch, .ps1 or vbs..

Thanks in advance.
1
I would kind to use a script that will look at a specific folder and if there are any .csv files it should join them.
All the csv files have the exact number of positions separated by a comma
0
I would like to know the batch commands for the attached input file that will do the following.
When it sees 01-ABCDA, or 01ABCDB - in position 4 'and' if it sees either 01230c, or 01232 in position 100,
then  it will change the last character from whatever 3 digits it sees at the end of those lines, to a ,008.


This is the input script in a .csv file.

5,A,01234,01-ABCDA,Y,1251/2,1772345,,20181003,20181107,20181114,,1234567890000,COMP ACCOUNTS PAYABLE,123 ROAD WAY,,TREEWAY,FL,01234-5678,,,,1234564870004,Somewhere Warehouse,200 Treeview Court NW,,Everywhere,GA,12345-1234,,,018-441-5522,41245,ABCORPBC,,USD,N,,,,,,,,,,N,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,00987894561230,01230c,152324,STEEL,,,,123.00,US,0.00,US,0.00,US,10.5000,0.0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,101
5,A,01234,01-ABCDB,Y,1251/2,1772345,,20181003,20181107,20181114,,1234567890000,COMP ACCOUNTS PAYABLE,123 ROAR WAY,,TREEWAY,FL,01234-5678,,,,1234564870004,Somewhere Warehouse,200 Treeview Court NW,,Everywhere,GA,12345-1234,,,018-441-5522,41245,ABCORPBC,,USD,N,,,,,,,,,,N,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,00987894561560,01232,152345,WOOD,,,,789.00,US,0.00,US,0.00,US,10.5100,0.0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,102
5,A,01234,67891,Y,1253/2,1775478,,20181003,20181107,20181114,,1234567890000,OTHERCOMP ACCOUNTS PAYABLE,123 ROAD WAY,,FOREST,TX,01234-5678,,,,1234564870004,Another Warehouse, 300 Apt View Court NW,Specific …
0
Hey Experts!  To keep a directory from filling up with backup files, I schedule this script to run once a month.  However during my testing, I noticed that the log file doesn't record what file(s) were deleted or if errors were encountered.  How do I record the outcome of the delete file action?  Thanks Experts.

cd "C:\tools\Scripts\Test"
forfiles /d -0 /c "cmd /c del /q /f @file"

Open in new window

0

Scripting Languages

27K

Solutions

20K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.