Scripting Languages

26K

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

This script gets the services on a set of systems, and returns the service name, 'logon as' and server it is on, then exports it to a csv file. This works fine.
I tried adding a where-object to it to remove "local System"  "Network Service" "LocalSystem" any by themselves do nothing, with a -or also does nothing. My attempts have been in vain, is there an easy way to filter out the chaf?
$datetime = (get-date -f yyyy-MM-dd-HH-mm)
Get-Content systems.txt| Foreach-object  {
  Write-Host "Retrieving Servers for $_ "    
  Get-WmiObject win32_service -ComputerName $_  | select Name,
  @{N="Service Account";E={$_.StartName}},
  @{N="System Name";E={$_.Systemname}}}|where-object { $_.StartName -notlike "LocalSystem"} |export-csv -path  D:\path\$datetime-Services.csv -nti

Open in new window

0
Cloud Training Guides
Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Hi All,

Greetings...

According to my work, I need to zip files present in a folder using batch script without using any 3rd party software.

I tried with below code ,but getting the error.error also attached below.

Any help regarding this would be highly appreciated.
'Get command-line arguments.
Set objArgs = WScript.Arguments
Set FS = CreateObject("Scripting.FileSystemObject")
InputFolder = FS.GetAbsolutePathName(objArgs(0))
ZipFile = FS.GetAbsolutePathName(objArgs(1))

'Create empty ZIP file.
CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)

Set objShell = CreateObject("Shell.Application")

Set source = objShell.NameSpace(InputFolder).Items

objShell.NameSpace(ZipFile).CopyHere(source)

'Required!
wScript.Sleep 2000

Open in new window


This code is present in zip.vbs file. We have to zip the files into Outputfile.zip file.
in command prompt  , I have entered below command

C:\Users\abc>Cscript zip.vbs input path  output path\OutputFile.zip

While executing this ,I got below error. " Path not found error" for both the input and output file path.

It will be helpful if anyone corrects me the mistake which I made in this script.
2
I have a simple script to check up down of ips. I have it displaying the way I would like, I would also like to save all of those up/downs to a text file. ( I have to send the results to someone else.) When I try to pipe it after the write-hosts are done, I get "An empty pipe element..."
Is there a simple way to get both?

Get-content c:\path\names.txt | %{
	If (Test-Connection $_ -Quiet -Count 2){
	write-host -foregroundcolor black -backgroundcolor green "$_ is UP"
	}
	Else{
	write-host -foregroundcolor black -backgroundcolor red "$_ is Down"
	}
}
|Out-File c:\path\result.txt

Open in new window

Thanks!
0
Dear,
I have to copy 2 files containted in one folder to dynamic set of sub folder.
Let's say
files are stored in c:\template
Destination folders are c:\Documents\A .......; c:\Documents\Z

I want the 2 files into all subfolders of c:\Documents
I have this but seems not working...


Get-ChildItem -Path c:\template | ?{ $_.PSIsContainer } | Copy-Item c:\documents $_.fullname
0
So I have this script, but when I run it, it's not working, it doesn't delete the files.
So I had someone write this for me, and it's supposed to keep 150 files, and delete the files from the directory listed, and delete all etl files. Am I missing something?


@echo off (need to change the below to the locations needed and file types)

call :delolder 150 "E:\ms\Output_On_08-10-2017__Time_17-12-31PM" "etl"
exit /b

:delolder
set type=%~3
set thedir=%~2
set keep=%~1
for /f "delims=" %%D in ('dir "%thedir%" /ad /b /s') do (
  echo Working on dir %%~fD
  for /F "skip=%keep% delims=" %%a in ('dir "%%~fD\*.%type%" /a-d /o-d /b 2^>NUL') do DEL "%%~D\%%~a"
)
echo Working on root dir %thedir%
for /F "skip=%keep% tokens=* delims=" %%a in ('dir "%thedir%\*.%type%" /a-d /o-d /b 2^>NUL') do if "%%~nxa" NEQ "%~nx0" DEL "%thedir%\%%~a"
exit /b

Open in new window

0
There is  a form with "post" that in the action it says:

(I run it with get and the line reads http://domain.com/test/?(variables))

http://domain.com/test

It doesn't specify the script that takes the form data to process and returns a result

I dont know in what language it is programmed in

I tried index.php (domain.com/test/index.php

the same for index.asp, default.php and default.asp but those scripts dont exist in the server.

I use chrome developers tools but it only returns  (index) which could be anything

Any ideas?
0
Is it possible to block a state via htacess?  Hypothetical, I am not allowed to business in CA so I want to block the state of CA?
Are there instructions on how to block all countries except the USA via htaccess?
0
I have a script that is not working, perhaps I'm doing something wrong.
So I've changed the variables below, but it's not actually deleting the files.
Any ideas what I'm doing wrong?


@echo off (need to change the below to the locations needed and file types)

call :delolder 7 "E:\mailflow backups" "*"
exit /b

:delolder
set type=%~3
set thedir=%~2
set keep=%~1
for /f "delims=" %%D in ('dir "%thedir%" /ad /b /s') do (
  echo Working on dir %%~fD
  for /F "skip=%keep% delims=" %%a in ('dir "%%~fD\*.%type%" /a-d /o-d /b 2^>NUL') do DEL "%%~D\%%~a"
)
echo Working on root dir %thedir%
for /F "skip=%keep% tokens=* delims=" %%a in ('dir "%thedir%\*.%type%" /a-d /o-d /b 2^>NUL') do if "%%~nxa" NEQ "%~nx0" DEL "%thedir%\%%~a"
exit /b
0
Hello it is possible download with wget a site with a href links?

For example we have an index,html that has only a list of a href links:

<p><a href="http://xxx.xxx.xxx/list.html">list 1</a></p>
<p><a href="http://xxx.xxx.xxx/list2.html">list 2</a></p>
.
.
.

Open in new window


Like that the index.html has a lot of a href.

Now the question is possible download all that index.html a href?
Also is considering for example the destinations list.html, list2.html,... are web pages with different elements, images etc.

We tried to use httrack and just download the index.html
and also we tried:

wget --convert-links -r http://xxx.xxx.xxx/index.html

Open in new window


and the same just download the index.html.

Any ideas?
0
So long story short I think it MAY have something to do with my shebang in my python. I know on our server we have a few different versions of Python and I installed my modules (paramiko and pysftp) in the correct place I believe. Honestly I have researched and am having trouble understanding how exactly the shebang works and knowing what interpreter it is pulling from or why the cron job is failing for that script (is there a log file perhaps to help determine the cause?)

Cron listing:
* * * * * /usr/local/mlb_cdt_download_newv2.py > /dev/null 2>&1
(Yes for testing purposes I am trying to have it run every minute just to see if it runs)

Script:
#!/usr/local/lib/python2.7
import os
import pysftp
import os.path
import paramiko

HOST=""
USER=""
PASSWORD=""
SUFFIX_TO_FETCH__AND_DELETE=".csv"
DESTINATION_PATH="/mnt/sas/ftp_mlb"

srv = pysftp.Connection(host=HOST, username=USER, password=PASSWORD)

def do_nothing(fname):
        return  " "

def fetch_and_remove(fname):
    if not fname.endswith(SUFFIX_TO_FETCH__AND_DELETE):
        return # skip files with wrong suffix
    dst_fname = os.path.join(DESTINATION_PATH, fname)
    dst_dirname = os.path.dirname(dst_fname)
    if os.path.isfile(dst_fname):
        return " "
    else:
        srv.get(fname, dst_fname)
        srv.remove(fname)

srv.walktree('.', fetch_and_remove, do_nothing, do_nothing)

srv.close()

Open in new window


For the record, running this script from the commando line works instantly and perfectly. But when trying to automate it through the cron I have no luck.

Any help trying to understand which interpreter my cron is trying to use and the location of such would be greatly appreciated.
0
Get 15 Days FREE Full-Featured Trial
LVL 1
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Please provide me with a command line or powershell command I can use to set a static IP address on a Windows computer.

IP address: 10.10.10.225
Subnet Mask: 255.255.255.0
Default Gateway: 10.10.10.250

DNS address: 75.75.75.75
Secondary DNS address: 75.75.76.76
0
Hi,

Any idea why the following is not ignoring hidden rows? I've tried ".hidden", ."SpecialCells(xlVisible)". Nothing seems to work.

Sub CountOffSpecs(sheet, col, status, row_)
    Dim i As Long
    Dim LastRow As Long
    Dim rarray() As Variant, dict As Object
    Dim v As Variant
    ReDim Preserve rarray(0 To 1)
    t = 0
    Set dict = CreateObject("Scripting.Dictionary")
    LastRow = sheet.Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To LastRow
        If InStr(1, sheet.Cells(i, status), "|") And Cells(i, status).EntireRow.Hidden = False Then
            resarray = Split(sheet.Cells(i, status), "|")
            lNumElements = UBound(resarray) - LBound(resarray)
            For l = 0 To lNumElements
                ReDim Preserve rarray(LBound(rarray) To UBound(rarray) + lNumElements)
                rarray(UBound(rarray)) = resarray(l)
            Next l
        ElseIf sheet.Cells(i, status) <> "" And Not InStr(1, sheet.Cells(i, status), "|") And Cells(i, status).EntireRow.Hidden = False Then
            resarray = sheet.Cells(i, status)
            ReDim Preserve rarray(LBound(rarray) To UBound(rarray) + 1)
            rarray(UBound(rarray)) = resarray
        Else
            'nothing
        End If
    Next i
    
    For m = LBound(rarray) To UBound(rarray)
        If dict.exists(rarray(m)) Then
            dict.Item(rarray(m)) = dict.Item(rarray(m)) + 1
        Else
            dict.Add rarray(m), 1
        End If
    Next m
    
    a = 1
    

Open in new window

0
Hi,

I am using Jupiter to write a read csv line.

So far,I wrote>>

(1)      import pandas as pd
(2)      pd.read_csv('C:/Users/USER1/Documents/Exports/ItemStatus.csv', sep=',')

but its giving me error. See text file. What I need to change to make this work…
python-read-error.txt
0
Greeting Experts,

I have a script that works w/o any problems as is but I need to add an email function that will allow it to send email in the event a website is not blocked. The way the script works (see below) is checked to see if status code of each site ( i.e. -eq 200) and checks to see if can be reached or not. Verify if our content controls are working or not. If it's blocked, then it will come back with "Site it blocked: URL, " or if not blocked then you will get "Site is not blocked at this time: URL."   I am looking to add an email function to the script to alert me and others in the case a site pops up as not blocked. Can somebody help me update this text ... thanks

$objXmlHttp = New-Object -ComObject MSXML2.ServerXMLHTTP
$URLlist = Get-Content "C:\FileLocation\List.txt"
Foreach($url in $URLList) {
    $objXmlHttp.Open("GET", $url, $False)
    $objXmlHttp.Send()
    $content = $objXmlHttp.responseText
    $status = $objXmlHttp.status
    $statustext =$objXmlHttp.statusText
    if ($status -eq 200) { 
        Write-Host "Site is Not blocked at this Time: $URL" 
    }
    else {
        Write-Host "Site is blocked: $URL "
    }
}

Open in new window



Output from Script:

Site is blocked: http://www.playboy.com 
Site is blocked: http://www.gambling.com 
Site is blocked: http://www.zob.com
Site is blocked: http://www.gmail.com
Site is blocked: http://www.dropbox.com
Site is blocked: http://www.facebook.com
Site is blocked: http://www.Twitter.com
Site is blocked: http://www.snapchat.com
Site is Not blocked at this Time: http://www.skydrive.com
Site is Not blocked at this Time: http://www.hotmail.com
Site is Not blocked at this Time: http://www.outlook.com

Open in new window

0
We have 2 Ms SQL 2016 tables
- both have same exact amount of columns
- both have same exact column types
- both have same total amount of 312,600 rows
- and both have the contents of files that has been restored to different location, SOURCE and DESTIN.
- both table have a field that supposed to be the same: alldata

We have been working with a series of queries in order to compare the 2 tables and identify if there is any difference  between the two.  However, each query have different results, the one that has 76 (which tells us  that THIS may be the query to use to officially compare 2 tables).

Nevertheless, we need some expert advice on constructing  a true compare query.  Below are the scripts we have been working with but the results are different:

Results '2' rows of this query:
SELECT aDESTIN.*, aSOURCE.* FROM aDESTIN
FULL JOIN aSOURCE ON (aDESTIN.alldata = aSOURCE.alldata)
WHERE aDESTIN.alldata IS NULL OR aSOURCE.alldata IS NULL

Open in new window


Results '76' rows of this query:
(SELECT * FROM aSOURCE
 EXCEPT SELECT * FROM adestin)  
UNION ALL (SELECT * FROM adestin
 EXCEPT SELECT * FROM aSOURCE) 

Open in new window


Results '38' rows of this query:
select * from aSOURCE
except select * from adestin

Open in new window


Results '312,654' rows of this query:
 select * from adestin d2
 left join aSOURCE d1 on d2.alldata=d1.alldata

Open in new window


Results '76' rows of this query:
SELECT * FROM aSOURCE
UNION SELECT * FROM adestin
EXCEPT SELECT * FROM aSOURCE
INTERSECT SELECT * FROM adestin

Open in new window


Results '29' rows of this query:
SELECT alldata
FROM (SELECT * FROM adestin
UNION ALL SELECT * FROM aSOURCE) data
GROUP BY alldata HAVING count(*)!=2

Open in new window


Question,

How can we know which query is the correct compare table query?

If the query is not present, please advice on script to  compare 2 tables.
0
Please provide me with a Power Shell or command line command to enable network discovery within Windows 10.
0
I am looking for best solution to subtract a date from a timestamp in my batch file. I have read calling a vbscript to make the calculation is a better option. Any help would be appreciated.

below is part of my script.

rem Setting the Start Date & Time that the batch was launched
===============================================================
set yyyy=%date:~10,4%
set mm=%date:~4,2%
set dd=%date:~7,2%
set hh=%time:~0,2%
set mn=%time:~3,2%
set ss=%time:~6,2%

set yyyy=%date:~10,4%
set mm=%date:~4,2%
set dd=%date:~7,2%
for /f "tokens=1-2 delims=: " %%a in ('time /t') do (set hh=%%a& set mn=%%b)
set ss=%time:~6,2%
set dstamp="%yyyy%"-"%mm%"-"%dd%"_"%hh%%mn%%ss%"
set dstamp2="%yyyy%"."%mm%"."%dd%"
set dstamp3 = dstamp2 - 6 days                  REM<---------------------------------------------------------this is the parameter i need changed
===============================================================

ren  "TRD_Cost.PSV"  "TRD_Cost_%dstamp3%_%dstamp2%.PSV"     REM<----------------------------------------------------renamed here
rem zip -j %exepath%\..\HostTran\Export\Dunnhumby\TRD_Cost_%dstamp2%.PSV.zip  %exepath%\..\HostTran\Export\Dunnhumby\TRD_Cost*.PSV >> %log%
rem move %exepath%\..\HostTran\Export\Dunnhumby\TRD_Cost_%dstamp2%.PSV.zip   %exepath%\..\HostTran\Export\Dunnhumby\backup\ >> %log%
rem del %exepath%\..\HostTran\Export\Dunnhumby\TRD_Cost*.PSV >> %log%

REM so this is what i want to rename the file: TRD_Cost_dstamp3 _dstamp2.psv where dstamp3 = 

Open in new window

0
I have been looking hi and low to auto populate user name and department in InfoPath browser form from several sources available
I tried User Profile Service but since Microsoft made it difficult in 2013 version and I am not an admin on the host I can't use this.
 I also tried User Information list. It worked perfectly in InfoPath preview but came up empty when I published the form.

So I tried to use JQuery and SP services. I captured all info in alarms correctly but cant figure out how actually place it in form controls. I use text boxes for all.
<script src="/sites/MySite/SiteCollectionDocuments/jQuery/jquery-1.8.2.min.js" type="text/javascript"></script><script src="/sites/MySite/SiteCollectionDocuments/jQuery/jquery.SPServices-2014.01.min.js" type="text/javascript">
</script><script type="text/javascript">

$(function() {        
     var thisUsersValues = $().SPServices.SPGetCurrentUser({
      fieldNames: ["Title", "EMail", "Office", "WorkPhone"],
      debug: false
});
alert(thisUsersValues.EMail);


alert(thisUsersValues.Title);
alert(thisUsersValues.Office);

alert(thisUsersValues.WorkPhone);

$('textarea[title="WorkPhone"]').thisUsersValues.WorkPhone;
$('input[title="WorkPhone"]').thisUsersValues.WorkPhone;
});
</script>
0
Greeting Experts,

    I have a standard script I use to check to see if our content controls are working ( i.e. verifying users can't get websites like Playboy). I need to change the script so it can check for multiple sites and then come back with the results in a .csv or.txt file for auditors. Can somebody help me with this script below?   thanks for the help    


$url = "http://www.Playboy.com"
$objXmlHttp = New-Object -ComObject MSXML2.ServerXMLHTTP
$objXmlHttp.Open("GET", $url, $False)
$objXmlHttp.Send()
$content = $objXmlHttp.responseText
$status = $objXmlHttp.status
$statustext =$objXmlHttp.statusText
if ($status -eq 200) { 
Write-Host "Site is Not blocked at this Time: $URL" 
}

else {Write-Host "Site is blocked: $URL "}

Open in new window

0
Free Tool: Port Scanner
LVL 9
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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 My Fellow Scripting Peeps whom I admire because you guys know your Sh1t =)

I would like to have a simple script that i can run every time i need to help friends & colleagues
to backup their data before attempting repairs or formatting.

My reason for a progress bar or progress percentage is so that I have more or less an idea
of how long the process will take or how long before it is finished.

oh by the way... This will be my very first run with robocopy but i have used xcopy and xxcopy in the past.

XXCOPY has a dim future and XCOPY is not as robust as robustcopy(robocopy)

I hope i got all the info you need.
0
A past IT person has enabled Windows Power Shell scripts (with .PS1 extensions) to run with full unrestricted access on an organization's Windows 10 computers.

None of these computers are added to a domain.

What is the best method to use to disable these Power Shell scripts so that they will no longer be able to run?

We don't want to take any chances with viruses or malware exploiting this security hole.
0
Hello,
Back when C# came out; I did not know how to pronouns this combination of C and a # (sharp).  Talking to a  developer, he chuckled when I said "C pound."
And now, when "reading" about generic decorators; it is not written as to  how to pronouns these;
*args, **kwargs
Might any one have the phonetics /fəˈnediks/ on these two decorators;
*args, **kwargs

Thanks
0
Hello,

I wrote a script to create a folder path and it works OK, however, it creates folders read only and I am trying to avoid that. I do not want it read only because then another process cannot create some files within the DATA folder. This is what I wrote and it is still creating the folders read only. Can you please let me know what am I missing?

mkdir -p "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA"
attrib -R "C:\Program Files\Microsoft SQL Server\*.*" /S /D
0
Hello,

I need to create a script that can automatically create username1 and username2 but also add sysadmin role to the NT AUTHORITY\SYSTEM username. It keeps saying that I do not have access to do it. If I manually add sysadmin role to NT AUTHORITY\SYSTEM and run the script it works fine and creates both usernames and their policies and roles but I have not been able to automate the sysadmin assignment. Below is my script:

ALTER SERVER ROLE [sysadmin] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
CREATE LOGIN username1 WITH PASSWORD = 'password', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF;
GO
EXEC sp_addsrvrolemember 'username1', @rolename = N'sysadmin';
GO
EXEC sp_addsrvrolemember 'username1', @rolename = N'dbcreator';
GO
CREATE LOGIN username2 WITH PASSWORD = 'password', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF;
GO
EXEC sp_addsrvrolemember 'username2', @rolename = N'sysadmin';
GO
EXEC sp_addsrvrolemember 'username2', @rolename = N'dbcreator';

Thank you in advance!
0
I have been using this power shell command to create a text files that lists the currently installed programs on Windows 10 computers:

Get-WmiObject -Class Win32_Product | Select-Object -Property Name > C:\PCapps.txt

Open in new window


The problem is that this command lists only the names of the installed programs.

I would like to run a command that will display the complete list of everything that is displayed within the Programs and Features applet: Software name, publisher, installed on, size, & version.

What is the correct syntax of a command that will display all this information?
0

Scripting Languages

26K

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.