Questions tagged [scripting]
A form of computer programming that — in the context of system administration — lends it self well to automating tasks.
1,849 questions
1 vote
5 answers
414 views
Remove commas in double quotes from CSV
I have a comma separated line I am using awk to extract fields from. Server1,poweredOn,10.0.18.70,"Blue, Green",POC,Vsphere However, when it comes to the text in double quotes ("Blue, ...
0 votes
0 answers
104 views
Find out whether an IP address is within a subnet in Mikrotik address list
In a script I use following line to find out whether some address is already in a list: /ip fire addr find where list=$listName address=$logIp The block looks as follows: :if ([:len [/ip fire addr ...
0 votes
1 answer
150 views
Unable to run BCDEDIT script with GPO
Unable to run BCDEDIT script with GPO This is more or less identical to the following post: Stumped on why my Startup GPO Script isn't executing BCDEdit correctly However, I am unable to respond ...
0 votes
0 answers
68 views
How to edit Azure Bicep files programmatically?
We have a lot of .bicep + .bicepparam files, and sometimes we have evolving ideas on how to structure those. This involves makes changes to many many files, to apply the new approach. Some of these ...
0 votes
0 answers
55 views
Cannot find login script
I inherited a quite simple network; 6 Windows servers (an FSMO, 2 DCs, Terminal server, File Share, SQL Server). Over the past Several months, I have resolved issues on the network, AD, FSMO, DNS ...
0 votes
1 answer
118 views
Starting Network Script in Task Scheduler as System with FQDN not working
i have a strange Problem and i hope someone can help me. What I’m doing: I am creating a Scheduled Task via GPO, which starts a Powershell script which is located on a network share. The Script should ...
0 votes
0 answers
47 views
Progress WS_FTP Professional Scripting
I am using the WS_FTP Professional vs 12.9 scripting and its basic process is going thru 10 folders and using mput to upload files from each of the 10 folders. Sometimes the folders are empty and I ...
0 votes
0 answers
107 views
How do parse an output of a variable in a batch script?
I am trying to run the following command: for /f "usebackq skip=1" %%i in (`mlcmd -cshost ***HOST*** -csport 2020 -csappname default -csuser ***UN*** -cspassword ***PW*** -scshost ***HOST*** ...
0 votes
2 answers
719 views
How to get global IPv6 address of the current machine?
I a bash script, I want to obtain the global IPv6 address of my machine for a given network adapter (on my case 'ens18'). To get started, I issued the following command: ip -6 addr This gives me the ...
1 vote
2 answers
10k views
Script to upgrade Windows 10 to Windows 11
I want to create a script to unattended upgrade my Windows 10 machines to Windows 11, but I don't want to install in the process all unnecessary applications like xbox. I'm trying to upgrade my ...
1 vote
0 answers
1k views
How to utilize client certificates now that cURL has removed support for NSS
We recently upgraded from RHEL7 to RHEL8 and one of this issues that wasn't straight forward to handle is how to utilize cURL with client certificates after cURL removed support for NSS? Previously, ...
0 votes
1 answer
93 views
Using destination file name vs destination directory when moving a file creates auditd logging dilemma
I am trying to log file operations using auditd (audit 4.0.1) and came across an issue with moving files. If I include the filename in the destination: mv /mnt/user/home/file.txt /mnt/user/home/...
0 votes
1 answer
77 views
.htaccess exposed to www since upgrade from apache 2.2 to 2.4
I just upgraded apache on my very old WHM server from 2.2 to 2.4, and now .htaccess files are being treated like text files instead of apache scripts. I also installed mod_ruid2 0.98 These three lines ...
1 vote
1 answer
796 views
Set service Startup Type to "Automatic (DelayedStart)" with PowerShell
I'm trying to script changing specific services to have Startup Type "Automatic (DelayedStart)". When I pipe the services into Set-CimInstance, I get an error that it "could not modify ...
0 votes
1 answer
423 views
Query Windows RDP monitor positions via command line
I am using Windows RDP (remote desktop) with a multi-monitor setup and I want my script to automatically detect the position of the monitors. Additionally, I only use some of my monitors for RPD with ...
0 votes
0 answers
171 views
Stop minikube on Ubuntu shutdown
I'm new to Kubernetes, I have internal instruction on how to setup the app locally using minikube. The problem is that I sometimes forget to stop the Cluster, if I do when shutdown the system it will ...
0 votes
1 answer
110 views
script to print dhcpd.leases info to syslog/file
So i'm running dhcpd on a server and to my knowledge the logs from dhcpd are not adjustable, if they are i'm dying to know how... Anyways, i need something to check the dhcpd.leases-file which is ...
0 votes
1 answer
578 views
Creating a computer account in AD using PowerShell
I want to create a new computer object in an AD domain. Below is the script I am using. Can someone tell where should create credential object for SRV1? In domain controller or in computer? If ...
0 votes
1 answer
81 views
Ubuntu/Orange Pi5 retrieve open tabs on Chromium (kiosk mode) via terminal - Powershell
I have a problem as of late where I am developing some PowerShell script to manage and update some digital displays. Please see below for my work in progress (By no means done). I am struggling to be ...
0 votes
1 answer
819 views
How to run a batch script completely and automatically on event such as sleep/hibernate and shutdown event using task scheduler?
I have written a batch script to perform some folder synchronizing task. I have scheduled the script to execute using task scheduler on events such as sleep/hibernate(kernel power event id 42) and ...
-1 votes
2 answers
14k views
Run commands remotely via SSH with a powershell script natively
We want to run commands on our network devices via SSH from within a powershell script. I know that we can do: ssh [email protected] But this is interactive and requires you to accept ...
0 votes
1 answer
94 views
Custom Script-based Backups
I'm a believer in having multiple restore solutions in place for the environment I support. I have a production backup solution for my Windows Server environment. It includes an agent on each box and ...
0 votes
1 answer
1k views
Can't get sub_filter to work in nginx, could it be an ownership/permissions issue?
I have http_sub_module installed, but the 'sub_filter' line is not working. I'm trying to use it for a dynamic nonce for CSP as per these instructions, replacing some text in script tags with the ...
0 votes
3 answers
2k views
Shell script capturing values from output of command
From a shell script, I run a ping command: ping -c4 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=58 time=34.2 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=58 ...
1 vote
1 answer
270 views
not able to send mails from linux ubuntu : 20.04 by using email mailutils (sendmail or mail keyword)
code : subject="mail subject" body="Hello World" from="[email protected]" to="[email protected]" echo -e "Subject:${subject}\n${body}" | sendmail -f "...
0 votes
1 answer
130 views
command took very much longer to run from script than in CLI
In an AWS EC2 serverm, OS: amzn2-ami-kernel-5.10 x86_64 Trying to diagnose an issue of a slow running cron script, identified a single line of command that took more than an hour to run, everyday. ...
0 votes
0 answers
730 views
Systemd service executing a script with error handling
I have the following issue: I created a systemd service which executes a script. This script contains several commands including psql commands which queries a database and stores the outcome into ...
0 votes
1 answer
5k views
Script to cleanup Windows.old remotely
Problem: A lot of older workstations on our networks are running out of hard disk space and I am looking for ways to stream-line the process of cleaning up some space. I understand I can use Disk ...
0 votes
2 answers
613 views
Bash script : Print all lines between two pattern in variables with slashes
I have a directory that looks like so : /path/to/files/data-file.1 /path/to/files/data-file.2 /path/to/files/data-file.3 /path/to/files/data-file.4 /path/to/files/data-file.5 /path/to/files/data-file....
0 votes
0 answers
191 views
Windows Server - create firewall rules from network trace?
A good basis for firewall rules would be Zero Trust - only allow what is needed. But in many cases, you do not know all the needed rules for a server connection. As a result in many evironments, the ...
1 vote
0 answers
509 views
mikrotik script is not run through GUI or Schedule
I get a problem that i have a one line script as bellow: /tool fetch url="https://......" When i run this script in winbox with "Run Script" button it does not work and after i ...
0 votes
1 answer
98 views
Secure method for automated copying of files over a root ssh connection
I currently have a few different services running on my home server and for simplicity, I have a single VM manage the certificates via certbot and just copy them across the network using SCP. The ssh ...
-1 votes
1 answer
70 views
Extract Pages from Various PDF Files into New PDF File [closed]
From a.pdf, I would like pages 2 and 5 b.pdf, pages 3 and 4 c.pdf, pages 7, 8, and 9 copied into a new PDF file. All input pdf files are ten pages long. I'm using bash, and plan to make many ...
0 votes
1 answer
126 views
Program started with Task Scheduler could not open my Printer
I have a C# program that executes some commands that generates a pdf and print it to a printer. The printer is hosted in a print server, so the way I accessed the printer is through my app config. (\...
0 votes
0 answers
131 views
Script to filter nginx logs to automatically running nftables
I have a domain served by nginx. nginx logs have this format: 178.128.120.151 - - [19/Jul/2023:20:27:25 +0200] "GET /favicon.ico HTTP/1.1" 301 162 "-" "Mozilla/5.0 (Windows NT ...
-1 votes
1 answer
1k views
Backup of organization's GitHub repository
Is there any guides/best practices/manuals describing how to organize periodical backup (and of course restore if needed) of entire organization's GitHub, preferably with metadata?
0 votes
1 answer
6k views
expect usage in bash script or bash command in expect script
I have a script below that works except for the expect portion: #!/bin/bash # invdir=/home/john/inventory for file in $invdir/$1 do if [ -z $1 ] || [ -z $2 ] then echo "You must enter a ...
0 votes
1 answer
423 views
Run custom s6 script in docker container once only
I'm using automation (ansible) to deploy a dockerised app (gitea). The app runs s6 in its docker entrypoint. I want to run my own script: after the container's first load (so the files and db are ...
0 votes
1 answer
87 views
time nohup ./script --> the time hasn't been logged [closed]
I need to measure the time that Firefox takes to build itself from the source code. Here's what I do normaly: nohup ./mach build > my_log.log & I then prepended time to it: time nohup ./mach ...
0 votes
1 answer
3k views
systemd not able to run some bash scripts
(Update with more info May 16, see end of post for journalctl messages) I've created a systemd timer and service with the purpose of running a handful of bash scripts. In particular I'm aimed at ...
0 votes
2 answers
14k views
How to run a python script in a specific directory automatically?
I have a python script that I wish to run at 5pm every Friday. How can I achieve that ? I understand I could do this through cron. However, as I have used relative file paths in the Python script and ...
1 vote
1 answer
47 views
What is the fastest method of getting a small amount of data from whitelisted servers?
I have a bunch of servers which build various different programs for various different systems. Once a build has completed, it gets archived into a single file and compressed, then an md5sum is ...
0 votes
0 answers
56 views
Script to scan log file
I have a log file with the content below. Let's call it as cpu_usage.out: 2023-04-12 12:04: CPU STATISTICS CRITICAL : USED:- 2.52% IDLE:- 97.49%|CpuUsed=2.52;0;1 CpuIdle=97.49;0;1 2023-04-12 12:05: ...
0 votes
1 answer
74 views
Is posible to write script that checks for differences between two patterns in configuration files
Linux. I have for example two config files. First: criticalexceptions => [ 'yum-updatesd-helper: error', 'cups: cupsd shutdown succeeded', 'hda: drive_cmd: error', 'end_request: ...
3 votes
2 answers
942 views
Vmware tags and Ansible , empty out in Ansible but VMs have tags
I am trying to filter out the list of VMs with specific tags. The sample playbook is as follows : - hosts: localhost gather_facts: false become: false vars: vcenter_hostname: ...
0 votes
1 answer
1k views
How to run a script in a OpenVPN server hosted in pfSense when client connects?
I've got an pfSense 2.6 instance which hosts OpenVPN for clients. I'm testing with client version OpenVPN Connect 3.3.7 (2979). There are some web endpoints with a dynamic IP addresses, so I can't ...
1 vote
2 answers
4k views
NGINX crashed and weird logs on access.log
When I came back home just now, I was checking my webserver if it was still running and I noticed that my NGINX server was not running anymore. I tried to restart my NGINX a few times by running the ...
0 votes
1 answer
338 views
How to execute a local script from a local client with Ubuntu on a remote VPS with Ubuntu without prompt?
I have made extensive research about how to setup and secure correctly our new VPS with a Ubuntu 22.04 OS for three weeks, and I have currently a good idea of what has to be done. However, I would ...
1 vote
1 answer
1k views
Stumped on why my Startup GPO Script isn't executing BCDEdit correctly
Environment: MS Server 2019 DC, Windows 10 Workstations joined to the Domain. The goal here is to set the Data Execution Prevention on a bunch of machines to OptOut. The way to do this via a command ...
1 vote
0 answers
140 views
Trigger Shell Script when new NFS filesystem is mounted
I am looking for a way to trigger a shell script when a new NFS filesystem is mounted. This would be used on Ubuntu 16/20 systems. The reason behind this is that on occasion, the connection to the NFS ...