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

Hi Experts,
I have this question after solving the following..
https://www.experts-exchange.com/questions/29108803/Script-to-read-all-files-of-specific-folder.html#acceptAnswerByMember
In that question I got a script how to count all records of files in one folder.
However now I need to know from that count how many are under one specific category.
Therefore I thought the best way would be to concatenate all files into one, just ignoring the headers.
And from there I will link to MS Access and get the results from a query.
Anyone has either a script for that or another way to accomplish the task?
Thanks in advance.
0
Cloud Class® Course: SQL Server Core 2016
LVL 12
Cloud Class® Course: 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.

Hi Experts,

I have to write a script which first read filenames in a directory and according to the name it should run jar files.
for eg filenames are according to the month and year-----07-18-01.txt ,07-18-02.txt , 08-18-01.txt,-------- (month-year-randomnumbers.txt).

My script should read these filenames , If moth-year matches with current month-year.It should run a.jar
otherwise b.jar

Current month year ,I am giving as
date +%m-%y

Open in new window

If filename contains value of this , It should run a.jar
if not ,it should run b.jar

Could you please help me to solve it..
Thanks in Advance.
0
I was experimenting with bash file descriptors and such.  I found a function to return the first available file descriptor:
#!/bin/bash

function find_next_fd() {
    local fd=2 # start at 2 to skip stdin, stdout, stderr
    local max=$(ulimit -n) # man 1 bash
    local found=0 # a flag
    while ((++fd < max)); do
        # if the file descriptor does not exist, 
        # set found and break
        ! true <&$fd && found=$fd && break
    done 2>&- # dump the bad descriptor error
    echo fd = $fd, found = $found
    return $found
}

find_next_fd
echo $?

Open in new window


This works pretty well.  If I run with no other settings, I get 3.  After executing `exec 3>somefile`, this script returns 4.  Execute `exec 3>&-`, and I get 3 again.  I wanted to see what happens when it gets to the limit.  Instead of creating descriptors up to 1024, I just removed the "!" from the test, i.e., it would return the first used descriptor.  I was expecting "0", but was consistently receiving "10".  I added these two lines into the while loop:
        echo Checking $fd
        ls -al /proc/$$/fd

Open in new window


This is a sample return:
#> ./fd-test.sh
Checking 3
total 0
dr-x------ 2 root root  0 Jul  4 04:51 .
dr-xr-xr-x 9 root root  0 Jul  4 04:51 ..
lrwx------ 1 root root 64 Jul  4 04:51 0 -> /dev/pts/1
lrwx------ 1 root root 64 Jul  4 04:51 1 -> /dev/pts/1
lrwx------ 1 root root 64 Jul  4 04:51 10 -> /dev/pts/1
lr-x------ 1 root root 64 Jul  4 04:51 255 -> 

Open in new window

0
Mac OSX question

I have a large library of digital media. Most of it is kept "offline" but the library software I use (Plex) uses media files to build the library and so I need to use placeholder files.

Using 30 second "this file is archived" videos I can easily catalog offline movies in Plex. I "rsync" the directory structure without files and then "do cp" a placeholder into each movie directory and rename using the parent folder name.

For TV shows this isn't practical as there can be hundreds of episodes per show. I would like to know if there is a way to duplicate the folder/file structure of a tv show, with many episodes under a single folder, using the same placeholder file.

To reiterate, the ultimate goal is to take a placeholder file eg. "placeholder720p.mkv" and use this file to recreate the source directory with the same filenames. So in the end I will have a folder that looks identical to the source, but consists of this placeholder file duplicated over and over. Also, there are non-alphanumeric characters and spaces in the filenames to be duplicated.
0
Hi,
So I am in the middle of changing a scheduled tasks account that it runs under as the current ones password is changed monthly.
I have added the account to the same groups for permissions as the previous account.

The basics of the script are:
Connect to FTP
Download files
Rename files
Move files
Archive files

Now when i run a test on the script it is for some reason it was unable to see the txt file that connects to the FTP account, i have to edit the command to point the script to the full path location "C:\tempfiles\ftpscript.txt" instead of it previously using "\ftpscript.txt", then it is also downloading the files into my documents and not the directory that it was downloading to before "C:\tempfiles"

It is as if the cmd prompt looks to different locations when run under those different accounts? I am not sure why it is now downloading in that location when it ran fine before. I think the only difference between the 2 accounts are that the previous account was the built in domain admin account and this is a new account we created which is also a domain admin account.

Script below:

:: Download all files via WINSCP
"C:\Program Files (x86)\WinSCP\winscp.com" /script=ftpscript.txt

:: Rename files
cd: "c:\tempfiles"
ren p3de* "temp file1"
ren p3tr* "temp file2"

:: Move files
COPY C:\tempfiles\* \\REMOTESHARE\SHARE\SHARE\*

::Archive files
MOVE "C:\Tempfiles\*.* "C:\tempfiles\archive"

Now so far i have amended the download command to …
0
Hello Experts,

Good Day...

I have a script which produces password protected  zip file in linux server..I write it using expect commands.

#!/usr/local/bin/expect -d -f
send "cd outputpath\r"
send "zip -e -rj OutputFileExtracted.zip /inputpath \r"
expect "Enter password:"
send "test\r"
set timeout 40
expect "Verify password:"
send "test\r"
set timeout 40
send"*#*"

Open in new window


But the above code is not producing any output.
When I m using the same commands (not expect commands ) in linux command prompt ,It is able to zip the files with password protected.
for eg :
cd outputpath
zip -e -rj OutputFileExtracted.zip /inputpath

Open in new window

then it asked for password
Enter password:

Open in new window

User input
Verify password:

Open in new window

again user input

Any one can tell me what is wrong with the expect commands? I tried with
spawn zip -e -rj OutputFileExtracted.zip /inputpath

Open in new window

in script..That also didnt give me output.

Thanks in Advance.
0
Hi Experts,

As part of my work I have following folder structure in linux server,

folders as 0,1,2,3,4,...9 and each folder contains subfolders as 0,1,2,3,4,...9.. After my job run ,These subfolders will have some pdf files..Once FTP is done from this server to another,I have to delete pdf files from each subfolders.

But script should not delete folders and subfolders.It should delete only the documents inside it.

I tried with rm command..But it didnt work.Do I need to use any loop?

Any Expert can help me on this?
1
Hi Experts,

I have shell script for zipping files
zip -j output.zip filepath;

Open in new window


I need to encrypt this zip file.So I modified like below
zip -e -j output.zip filepath;

Open in new window


But we need to provide expect commands also right.

Enter password:
Verify password:

How can I integrate expect commands along with this?Shall I need to put extra text file for expect command or in the same script can we add expect commands?

Any help regarding this would be highlight appreciable.
0
Hi Experts,

Greetings...

I have to move files from different folder to other folders in between linux servers using batch script.

Script will be present  in the first server

output server name : name
username : uname
password:paswrd

files are present inside ---- inputpath/5/6/abcde.pdf , inputpath/5/7/cdesf.pdf ,.........etc
OutputFile path in second server=     outputpath/5/6/abcde.pdf ,outputpath/5/7/cdesf.pdf,................

Any help regarding this would be highly appreciated
0
I had a Problem when i am uploading image into Registration page all the fields are showing in the console expcept image field , data is not storing into database it creating null object am attaching a file reagrding that null object....
0
Upgrade your Question Security!
LVL 12
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Hi Experts,

I have shell scripts named as a.sh,b.sh ,c.sh and one jar file also.

Have to call these all  files  from a single sh file (main.sh ) by series not parallel.

Any help regarding this would he helpful.
0
Hi Experts,
Looking for a script that gives me all large files created on the server in the past 10 days..
should return file name, date created, size of file, user created.
Thanks in advance.
0
I have an old Windows 7 Workstation that belongs to a workgroup. It is responsible for 2 major functions that both require a separate drive mapping to 2 different servers on our Windows 2012 domain. The mappings are unstable and even though I check to reconnect box one or both manages to have a RED X every couple days. Security will not allow me to give the end user the password to the AD service account I use to map the drives. So everyone couple of days one of the major functions comes to a halt until I am contacted and if I am not available phones start ringing, emails start getting sent to my boss and you get the jest. I need a solution what I can give the end user that allows her a one click fix to remap. I know I can write a .bat file but am concerned I may need to hard code the password in the script which will be another security issue. Or is it possible to use local GPOs to unmap or remapped the drives each time the user logs in? I just need a quick and simple solution. Something very easy to fix gets escalated to a major issue real fast and I need a way to prevent this. All suggestions welcome even if it is different than a script of local GPO. BTW, I know I could put the workstation on the domain but that creates other issues with internet access one of the processes the device is used for....thanks
0
Hi everyone!
I am trying to do a few things in my bash script (script1.sh):  pass logicals/variables to my SAS program (program1.sas), execute SAS code (program1.sas), check with "errstat" for specific errors related to SAS code conditions that I set up in my SAS code, and also check with "logerrchk" SAS log file for any errors in the SAS log.  
I think most of the script is correct but I am not sure about both checking errors (errstat" and "logerrchk").

 Please note: variable/logicals (file1, file2, plog, and errstat) are also defined in the SAS program.  

 Please provide any suggestions or examples if you can.
 Here is what I have so far:

#!/bin/bash
#script1.sh

# Creating variables for directories
export DATADIR1=/root/alldirs/2018/data1
export DATADIR2=/root/alldirs/2018/data2
export DATADIR3=/root/alldirs/2018/data3
export PROGDIR1=/root/alldirs/2018/prog1

#Creating variables for data files that are used in program1.sas and final log file 
export file1=${DATADIR1}/sasdata1.sas7bdat
export file2=${DATADIR2}/sasdata2.sas7bdat
export plog=${DATADIR3}/sas_program.log

#executing SAS program
sas ${PROGDIR1}/program1.sas -log ${DATADIR3}/program1.log

#checking for errors in SAS log file
logerrchk=$?     
   if [[ "$logerrchk" !=0 ]]; 
   then 
       echo "--- Error: Abnormal end in program program1.sas. Check log file! ---" >> $plog
       exit 2
   else
       echo "--- Program1.sas run successfully! ---" >> $plog
   fi
  
#checking for specific errors 

Open in new window

0
Hi All

Using Microsoft SQL 2016, I built the below script

DECLARE @startdate datetime
DECLARE @enddate datetime
DECLARE @facility varchar(8000)


SET @startdate = '2018-01-01'
SET @enddate = '2018-01-30'
SET @facility = 'PENRITH,GOLDCOAST,PERTH'

	------------------------------------------------------------------------
	SELECT
	 CAST(t.trans_no  as varchar(100))								as [Transaction Number]
	,CAST(t.invoice_no  as varchar(100))							        as [Invoice Number]
	,inv.account													as [Account Name]
	,act.acct_type												as [Account Type]
	,ty.descrip													as [Account Description]
	,CAST(r.reserv_no as varchar(100))								as [ Reservation Number]
	,t.orig_dt														as [Booking Date]
	,t.start_date													as [ Date]
	,DATENAME(DW,T.start_date)									as [ Day of Week]
	,DATEDIFF(DAY,t.orig_dt,t.start_date)							as [Days Booked to ]
	,t.department												as [ Product Hierarchy]
	,t.category													as [Category]					
	,i.descrip													as [ Product Name]
	,t.special														as [Special]
	,mk.descrip													as [Marketing Code]
	,t.quantity													as [Quantity]
	,CAST(t.pts4qty  as varchar(100))								as [Minutes]	
	,address.zip													as [Postcode]
	,au.region1													as [State]
	------------------------------------------------------------------------
	,t.tax_amount													as [GST]
	,t.extension/1.1												as [ Revenue]
	

Open in new window

0
Hello,
I would like to have a logon script that I would put in my active directory users.
This script shoud:
1. Create a folder at a network place \\cadc03\timesheets\first name and name of the user (taken from AD)
2. Map this folder in the user profile.

Ofcourse if the folder already exists, it should disregard the first step.
Thank you.
0
Hello all,

I am working on a script to install application, it works good. but the setup file need to have some permissions on folder in C.
what can I include in the script to modify permission of particular folder?

Regards
0
I have powershell codes and working okay with 1 attachment.
How can I add all three attachment into this powershell?

The goal is to use this powershell to send 3 attachments in one email.

Thanks
$Username = "smtp";
$Password = "Fire";
$path01 = "E:\Reports\AgentSummary\Agent-Sales-Summary1.xls";
$path02 = "E:\Reports\AgentSummary\Agent-Sales-Summary2.xls";
$path03 = "E:\Reports\AgentSummary\Agent-Sales-Summary3.xls";

function Send-ToEmail([string]$email, [string]$attachmentpath){

    $message = new-object Net.Mail.MailMessage;
    $message.From = "IT@s.com";
    $message.To.Add($email);
    $message.Subject = "Agent Sales Summary Report";
    $message.Body = "Agent Sales Summary Report. Please review the attached file. Thank You";
    $attachment = New-Object Net.Mail.Attachment($attachmentpath);
    $message.Attachments.Add($attachment);

    $smtp = new-object Net.Mail.SmtpClient("smtp.sendgrid.net", "587");
    $smtp.EnableSSL = $true;
    $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
    $smtp.send($message);
    write-host "Mail Sent" ; 
    $attachment.Dispose();
 }
Send-ToEmail  -email "sales@receiverxxx.com" -attachmentpath $path01;

Open in new window

0
1. Can someone explain me if there is any changes in .cloginrc file, I need to run the rancid-cvs and rancid-run,
2. When i am trying to login i can see that the username is not pulling from what is there in .cloginrc.

For Eg:
(Under my clogin file)
I have mentioned
add user 1x.x.x User1
add password 1x.x.x       {password}
add method 1x.x.x telnet ssh

But when i am trying to login, i can see that username is in rancid. I am not sure why its happening. And to make sure that if try firewall login or normal login, its going with actual username only
0
Introducing Cloud Class® training courses
LVL 12
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

I need to add X-header at the beginning of multiple "XML" files.

The X-header would be:

"X-Header Message Type: IM"

The XML files are going to located on a desktop folder name "XML FILES".

It should ignore the XML file name just open every file and add "X-Header Message Type: IM" at the beginning.
0
Hi there, we are experiencing lookouts across our network as Lync saves users' password automatically in credential manager (Win 7). When users change their passwords, the lookouts start to happen. We're aiming to develop a script to delete such entries, but the entries can't be deleted. I've been digging about this topic but I haven't come across with any solution. I get an error message saying "CMDKEY: Element not found.", but the certificate is actually stored in credential manager. This is what I'm using:

@echo on
setlocal
set Filter=LegacyGeneric:
for /f "tokens=1*" %%a in ('cmdkey.exe /list ^| find /i "%Filter%"') do (
      echo Removing credentials for target '%%~b'
      cmdkey.exe /delete:'%%~b'
)
pause

This is the entry I have in credential manager: Target: LegacyGeneric:target=Microsoft_OC1:uri=user@domain:certificate:OCS:1

I really appreciate your help. Thanks.
0
To add text (hashtags) to a series of text files, each set of text files is in a named folder/directory. Recursively I want to add both #directoryname AND #filename(without extension) to the end of each text file, though anywhere will do, such as the beginning. So to do this for every folder's content in the head folder.

I am wondering if AWK can do this since I've had a bit of practice with it, albeit at a simple level.

later: ok so pwd gives me the absolute working/current directory, but I need just the cd on its own... not found anything does that yet.

Anthony


Context (i.e. the problem instead of the solution): exporting Apple Mac Notes using Exporter app. which creates the text file hierarchy, the import to Bear app, which uses the hash tags.
Doing this also to an Evernote export enex file and basecamp to follow
0
from 5:30pm - 7:30am everyday i want to forward and bcc any google email that comes in from test@test.com to test2@test2.com.
from 7:30am - 5:30pm I what to turn off the forwarding.

Can i achieve this by using a Google Apps Script ?

Ultimately i need this to be automated so it doesn't require manual intervention

Cheers

Troy
0
This question is related to EXTJS 4. I have a datefield which comes with picker. But the events are not fired and so not able to pass the selected date value to the controller in Spring.
In getStandardEffectiveDateFormParameters() method doesn't have date value. datefield  events not fired.
Here is the code.

var standardEffectiveDateForm = new Ext.form.FormPanel({
        title: "Update Standard Effective Date",
        width: 250,
        height: 240,
        frame: true,
        items: [
        	nationalstateSFDField = new Ext.form.Checkbox({
                xtype: 'checkboxfield',
                name : 'nationalstateChoice',
                boxLabel:'(Check this box for State Transfer)',
                fieldLabel: '<span style="color: rgb(0, 0, 0);white-space:nowrap;">State&nbsp;Transfer</span>',
                checked: false,
                listeners: {                     	   
                    'change': function () {
                    	var state_transfer = this.getValue();   
                    	if (state_transfer === true) {
                    		Ext.getCmp('stateSFDChoiceField').show();
                    	}else{
                    		Ext.getCmp('stateSFDChoiceField').hide();
                    	}
                    }
                }
        	}),
        	stateSFDField = new Ext.form.ComboBox({
        	  xtype: 'combobox',
	          allowBlank: false,
	          id: 'stateSFDChoiceField',
	          fieldLabel: '<span style="color: rgb(255,

Open in new window

0
I am having issues with the Scheduled Task. I can run the script manually via PowerCLI 6.5 witch prompt for windows login every time but no issues after, but the Scheduled Task just continues to run with no stopping in sight and nothing happens.

can someone please tell me how I can Schedule this to run. things to bear in mind is that our vCenter is on a different domain so I have to use those credentials from the domain am logged from.

this is the link I have tried to follow, but am just not able to task schedule. If someone can write a batch file to run this script that don't prompt for credentials every time I manually run it?

http://www.virtu-al.net/vcheck-pluginsheaders/vcheck/

I followed the below link as well, but that didn't work and I think its because our VM is on another domain?

https://virtualdatacave.com/2015/12/vicredentialstore-and-scheduling-vcheck-with-ad-user-and-vicredentialstore/

vCenter 6.0 update 2
PowerCLI 6.5
vCheck 6.25

Thanks
1

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.