Questions tagged [scripting]

A form of computer programming that — in the context of system administration — lends it self well to automating tasks.

Filter by
Sorted by
Tagged with
0 votes
1 answer
2k views

Why are cron jobs not being logged by rsyslog on Debian 10 buster?

(I figured this out, it was multiple problems...I'm leaving this as is and explain the process I took to resolve in my answer to this question) I'm working on a simple Ruby script that runs as a cron ...
0 votes
1 answer
2k views

Bash - Run 'chage' Command Against Each User Account

I have to audit the users accounts on our linux servers in each environment so I want to script checking whether each account is expired or not. I have a for loop that's pulling user accounts listed ...
0 votes
1 answer
631 views

exec 2>&1 – execlude some command from being logged to file

I have the following in my bash script: # catch input for log-data exec > >(tee -i ${LOG}) exec 2>&1 I want to exclude one command from being written to this log file, but the following ...
0 votes
2 answers
133 views

Bash-script: run another script on bottom as an other user

I have a bash script that runs over crontab as root. On the bottom of that script I want to run another bash script as another user in a subshell (detached). How can I do that The normal command would ...
0 votes
1 answer
34 views

Simple bash syntax failing passwd

Whenever I try to enter the password for a new user through pipe it doesn't work for me.. this is the command: echo "${PASSWORD}" | passwd ${USER_NAME} However it fails to work, what am I ...
4 votes
2 answers
18k views

Copy-item with multiple filter

How can I use copy with multiple filter values? For example, it works if I specify only 1 value to filter (*.jpg) Copy-Item -Path Y:\TEST -Recurse -Filter *.jpg -Destination D:\Users\MS5253\Desktop\...
-2 votes
1 answer
732 views

Passing a list as parameter in a call within a windows bat file

For a set of project, I need to automate granting access to users and would write a *.bat I would write something like this (but more complex): @echo off CALL :grant "user1 user2" "read ...
0 votes
5 answers
10k views

Restart a Windows service from a script?

I know there are several similar posts on the subject, but what I would like to know is how to re-start a service that has already been stopped. Is there a .bat or .vbs script that would check if the ...
14 votes
5 answers
52k views

How to add a script to startup and shutdown in debian?

the title pretty much sums it up. how do I add a startup.sh and shutdown.sh of my server app to the startup and shutdown sequence of the Debian OS?
0 votes
1 answer
1k views

Powershell error when adding filepath

The script looks like this: $searchOU='ou=Servers,dc=mydomain,dc=NET' Get-ADComputer -filter * -SearchBase $searchOU | Foreach-Object { $server = $_.Name ([ADSI]"WinNT://$($_.Name)/...
0 votes
1 answer
70 views

Script without put ran as administrator leaves no file [closed]

I am trying to run this script as administrator. When I run it without admin rights the log file is save in C:\Windows\System32. I put echo %~dp0 in the script and it echos to the current directory. %~...
1 vote
2 answers
7k views

8: Syntax error: word unexpected (expecting ")")

The following code: weekday=$(date +%a) day=$(date +%d) month=$(date +%m) if [[ ( $month == 03 || $month == 10 ) && $weekday = "Sun" && $day > 24 ]] then # ...
1 vote
1 answer
594 views

Any PowerShell Script to Backup and restore Ms-sql database using dB username and password?

I am looking for a PowerShell script which can take backup and restore MS-SQL databases using SQL authentication.
26 votes
15 answers
26k views

Scripting alternatives to Bash shell scripts

I have just migrated to a UNIX workstation. My memory of Bash shell scripts has faded since school and I find the syntax to be highly confusing. I am wondering what other scripting languages are ...
2 votes
1 answer
4k views

Recursive PowerShell script to protect all OUs and Objects from Accidental Deletion

I'm sure there has got to be an easier way that what I hand-jammed.... I'm trying to write and run a PowerShell script that will set the ProtectFromAccidentalDeletion flag to "true" ...
0 votes
1 answer
2k views

Can't figure out how to get started with powerdns-recursor lua scripting

I have a server (Ubuntu 12.04) where I run powerdns-recursor. I'm trying to add some logic to certain requests and have got my target set on lua scripting for powerdns. I don't seem to be able to ...
11 votes
2 answers
46k views

How to export a Full SMTP Log in Office 365

In Office 365, is it possible to export the SMTP log? Maybe in powershell or any other way. My goal is to have a complete overview of all messages send from and to a specific domain.
-1 votes
1 answer
438 views

What is the Script CMD for add rule for Routing and Remote Access in Firewall?

Does anyone know the script from Command Prompt to add a rule for Routing and Remote Access ? Routing and Remote Access (GRE-Out) Routing and Remote Access (L2TP-Out) Routing and Remote Access (PPTP-...
-1 votes
2 answers
716 views

SCP exit 0 when using un-initialized variable and fail to copy

I am trying to test if a file fails to transfer using SCP. I noticed if I use a un-initialized variable, I get exit 0 even though the SCP fails. For example, I have an empty variable called ...
2 votes
1 answer
4k views

Does MS Teams write to Event log?

I'd like to trigger a script action upon MS Teams client launch. My first guess was to hook it on an event in the Event log. However, I was unable to find if the app actually writes to the Windows ...
0 votes
1 answer
354 views

Renaming a tar file in unix script

cd /var/opt/sw/e4/data/dev/e4_dev/DEVL3/EW/EWD1/DATA/AED/INPUT for file in *;do tar -czf ../OUTPUT/"${file}".tar; done According to the above code the files in input path eg. aedlog, aaalog....
4 votes
2 answers
6k views

Problems with bash variable expanding with single quotes

I have a variable that I build like this : ATTSTR="" for file in $LOCALDIR/*.pdf do ATTSTR="${ATTSTR} -a \"${file}\"" done The variable now contains (notice the whitespaces in the file name) : ...
5 votes
3 answers
11k views

Linux command to find and delete certain files, but output the result or verbose mode?

So I use these command on my storage server to clean up some junk, but it doesn't produce any output or result. I found the syntax online somewhere and just modified for which files I need it. What ...
15 votes
3 answers
47k views

Dismount USB External Drive using powershell

I am attempting to dismount an external USB drive using powershell and I cannot successfully do this. The following script is what I use: #get the Win32Volume object representing the volume I wish to ...
19 votes
6 answers
146k views

Find GUID of MSI Package

How can I find the GUID of an MSI package? I would like to script the removal of a program on a large number of desktops by using: msiexec.exe /x ProductCode Any reason why this would not work ...
5 votes
1 answer
6k views

How does Outlook identify "Extra Line Breaks"

I am writing a script that emails the output to me, and I read it in Outlook. For some reason Outlook removes all the line breaks in the message, and gives me a little notice that it has removed the ...
1 vote
6 answers
38k views

How can I copy a file from one Windows server to another in a script?

I have two Windows 2003 servers, and I want to write a backup script on one that will copy a file to the other. What's the most idiomatic way to do this on Windows? Essentially, I'm looking for the ...
59 votes
8 answers
271k views

Run a shell script as a different user

What's a good way of running a shell script as a different user. I'm using Debian etch, and I know which user I want to impersonate. If I was doing it manually, I would do: su postgres ./backup_db....
1 vote
3 answers
2k views

How to get a debug output from the find command?

I have the following find command: find /home/ -type d -name "something" what I want to achieve is to know which directory/file is checked by the find command no matter the fact that it does or ...
21 votes
7 answers
19k views

Setting the Timezone with an automated script

I'm writing scripts to automate setting up new slicehost installations. In a perfect world, after I started the script, it would just run, with no attention from me. I have succeeded, with one ...
5 votes
7 answers
17k views

How to 'echo "" > x' on multiple files

What is the best way how to empty a bunch of files in bash? As far I've been doing this echo "" > development.log echo "" > production.log I don't really want to delete those files, so rm is ...
7 votes
8 answers
16k views

how to write a script that only acts on new log entries

I feel like this should be a simple thing but I am having a hard time figuring it out. I am trying to write a script that will monitor one of the apache log files and take some specific action. But ...
2 votes
1 answer
641 views

In Debian-based script: how to determine if kernel changed and needs reboot?

How can we (more) easily determine if a kernel-change-reboot is required in Debian, other than doing this in a script (which is a bit cumbersome)? Ubuntu has /var/run/reboot-required and per our ...
0 votes
1 answer
850 views

multipart/mixed content type and boundary refused by Amavis

I'm writing a Ruby script that send SMTP email. The email is divided onto 3 parts: headers, body and attachment. Unfortunatly, I'm struggling to satisfy an Amavis requirement: properly writing the ...
5 votes
6 answers
48k views

How to test if two given files are identical?

Just updated the code... I get out everytime on the "else" sequence. You can download the update.sh file from my server. it only contains echo "Hallo update" Updated code (03.11.2015) #/bin/...
1 vote
0 answers
2k views

PowerShell Script to create a VPN connection for all users

I have the following PowerShell script that creates a VPN connection and a desktop shortcut to Rasphone. # # Powershell script to create a client VPN connection to a Meraki MX. # # Configuration ...
5 votes
3 answers
6k views

Thunderbird - Login Script to create user and email account

Is there anything out there that will let me script via active directory and login scripts the creation of a thunderbird user profile and associated email account? I looked to do this in Outlook 2010, ...
0 votes
1 answer
93 views

Installing the Scripting Extension Python - SNAPSHOT JARs

I am trying to install the Geoserver Scripting Extension - Python (description). After downloading geoserver-2.17-SNAPSHOT-python-plugin (my Geoserver is 2.17.0) I followed the instructions: Extract ...
0 votes
1 answer
2k views

Systemd python script won't log (buffer cause)?

Although the problem exposed here seems very similar, none of the solutions provided work. Context : Raspberry Pi Zero W, Raspbian Lite (2020-08-20) I want to register a python3 script as a service, ...
-2 votes
2 answers
1k views

Linux Bash Scripting using grep sed and cut command to display ip address with port number

Can any one please help me I need a output of "192.168.1.1#53" by using these 'grep' 'sed' and 'cut' command mandatory in linux bash scipting in given below text. ;; Query time: 29 msec ;; ...
0 votes
0 answers
2k views

Correct way to run scripts in automated, unattended Windows installation

I have some custom scripts that I have written to customise Windows 10 such as removing bloatware and setting file explorer options via Registry Editor that I use to apply to all users and/or the ...
0 votes
1 answer
1k views

PowerShell: How to check a recurrent week time interval?

I need to create a PowerShell script, able to collect some data at each minute. However, this script cannot run during the "technical windows", that are scheduled to occur at the same week ...
1 vote
0 answers
676 views

Capturing output of remote process from sysinternal's psexec Script

I'm trying to deploy a program throught PSexec with a script from Bat file to use one CMD instance per computer and not one after the other. I need a log to be generated on my local server to be sure ...
0 votes
2 answers
1k views

Recursively delete empty folders with verbose output

This should be fairly simple, but I am not sure what i'm missing. I'd like to recursively delete empty directories, and get an output for what's being deleted, this command works for sure, but I just ...
0 votes
2 answers
204 views

Bash script with output

I have a server that needs to send daily some files to remote machines. I have done this script in order to automate this task. What I need to insert on this script in order to see if this task as ...
-1 votes
1 answer
64 views

How to rename multiple files by adding word from that file?

I have files : file name: report_2020-10-13-17-11.txt Contain : ... this report was prepared by=John ... file name: report_2020-10-13-17-12.txt Contain : ... this report was prepared by=Doe ... ...
9 votes
4 answers
90k views

Retrieve internet proxy server address via PowerShell

I have to retrieve the proxy server address and port via PowerShell, so I can use the Invoke-Webrequest -uri http://some-site.com -Proxy command. The expected output should looks like http://proxy-...
4 votes
1 answer
1k views

Error while checking IPv6 address using Get-NetIpAddress

Get-NetIPAddress -AddressFamily IPv6 -AddressState Preferred -SuffixOrigin DHCP | Select IPAddress I am facing the error below while executing above script. It shows the correct IPv6 configurations ...
0 votes
3 answers
4k views

How to clear contents of all the files using find command

Is there an easy step to clear contents of all ".log" file using find command. Currently i am using "echo -n > filename.log" i have tried echo -n > /var/application-logs/*.log but it is not working.....
-4 votes
1 answer
804 views

How to add credentials to bitlocker script

I'm trying to create a script to see if the bitlocker works or not. If it works, then a file is posted in the c:\ folder We will call "yes" if the bitlocker does not work then add password ...

1
3 4
5
6 7
37