Questions tagged [scripting]
A form of computer programming that — in the context of system administration — lends it self well to automating tasks.
1,832
questions
0
votes
1
answer
37
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
14
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
68
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 ...
0
votes
0
answers
35
views
not able to send mail with attachment from linux ubuntu : 20.04 by using email mailutils (sendmail keyword)
code :
subject="Service resilience service status"
body="Service is down"
from="[email protected]"
to="user@domain.com"
attachment="/home/ubuntu/...
1
vote
1
answer
49
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
40
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
64
views
I need to only get all active users in a Security Group, i can list all users but i get both active and inactive users
Need help to correct the scipt. The group FA-xxx-yyy-zzz has loads of users and undergroups in it.
This what i figured out so far is:
Get-ADGroupMember -Identity "FA-xxx-yyy-zzz" -Recursive |...
0
votes
0
answers
118
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
192
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
1
answer
49
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
58
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
127
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
51
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
35
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
31
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
67
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
269
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
0
answers
13
views
Managing ougoing RDP sessions (MSTSC)
I am trying to automate a process where a user can establish an ssh tunnel in WSL then use that tunnel for an RDP connection using MSTSC. The same script might launch multiple instances of MSTSC using ...
0
votes
1
answer
963
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
116
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
60
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
0
answers
122
views
Wireguard-ui: `Bad PATH_INFO : /login`
I've successfully installed Wireguard + UI to a Debian11 VPS with this AIO script.
But if I open the http://localhost:5000 via Webmin tunneling, I get this error:
Bad PATH_INFO : /login
How do I fix ...
0
votes
1
answer
556
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
3k
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
32
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
47
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
48
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
244
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
0
answers
82
views
Sending simulated key presses to a specific process using python script in linux
On my Linux system I have opened a Telnet session. On the other tab I am running a Python script and giving commands to the Telnet session using mkfifo file redirection. But I am not able to simulate ...
0
votes
1
answer
550
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 ...
0
votes
2
answers
885
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
145
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
364
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 ...
0
votes
1
answer
89
views
Fswatch observing folder for new files error from the example doc
I am trying to "listen in" on changes in a particular folder, then once a file comes in, I want to copy the file to another folder. I figured fswatch would be a great choice for this.
And as ...
1
vote
1
answer
517
views
SSH config: How to automatically execute an interactive script locally before connection?
Background:
I have a local script that needs to execute locally as a pre-requisite to making an ssh connection.
The script is already working, but currently users need to run the script, then make an ...
-1
votes
2
answers
390
views
how can I detect if g++ compiled without errors
I have a script file to automatically compile a C++ program, then automatically run the executable.
script
g++ -o bin/program main.cpp
bin/program
The problem is, sometimes the compiler encounters ...
1
vote
1
answer
35
views
Scripted Password Change Does Not Survive Reboot Unless One Login Occurs - Debian 11
I am trying to automatically set the root password to random characters via bash script. The script is part of a Vagrant shell provisioner. If the script runs the password change only, I am able to ...
1
vote
1
answer
85
views
htaccess syntax issue when moving script to a subfolder
I have recently purchased a script but this script only works in public_html folder . I need to install it in a subfolder named shop ( public_html/shop/ ) . Now the following .htaccess rules work ...
1
vote
1
answer
486
views
Divide one .pem file containing several certificates to several new .pem files
I am currently trying to figure out how I can divide one .pem file, containing several certificates to several new .pem files, but I do not know where to start...
The first .pem file looks like this:
-...
0
votes
1
answer
211
views
Alter Database recovery model & Shrink log, DB dynamically
I normally do on daily basis these operations in GUI
Alter database to simple recovery model
shrink log file
shrink database file
Alter database to full recovery model
I can understand script but ...
0
votes
1
answer
598
views
Trying to start script but keep getting error syntax error near unexpected token `stop'
#!/bin/bash
#
case “$1” in
start)
echo -n “Starting Queue Manager”
/opt/mqm/bin/strmqm QMPROD1
sleep 10
echo -n “Started Queue Manager”
#
...
1
vote
1
answer
327
views
Powershell Script to check free disk space on servers
I am in need to check free space on servers but I am getting more than enough details.
DeviceID : C:
DriveType : 3
ProviderName :
FreeSpace : 76691152896
Size : 160482455552
...
2
votes
0
answers
34
views
Disable computer on a schedule
I'm looking for a way to disable end user access to a Windows 10 workstation during a given period, say, from 8pm to 8am.
It doesn't need to be superuser-proof.
It doesn't need to be reboot-proof.
...
0
votes
0
answers
61
views
Need help to Split the below HTML text file in two parts using linux scripting
I have a html main.txt file, I need help to split it in two parts.
headpart.txt and bodypart.txt.
Below is my html main.txt text file - Original
<p class=\"auto-cursor-target\"><br /...
1
vote
2
answers
1k
views
winget not working unless I do
When I open Powershell, and type winget - this is the response:
winget : The term 'winget' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of ...
1
vote
1
answer
701
views
How to monitor scripts executed via cron and perform action on elapsed times?
I run numerous scripts via CRON throughout the day, and as they rely on third-party providers which sometimes are slow, I currently run them like so timeout 60m bash /script.sh and that's worked great ...
0
votes
2
answers
3k
views
Is it possible to check a client Windows PC's registry to see if it is joined to an Azure AD domain?
On a Windows PC joined to a 'traditional' Active Directory domain, querying Win32_ComputerSystem or Win32_NTDomain returns the domain name.
It seems that if it's Azure anything [joined], those classes ...
0
votes
1
answer
381
views
PowerShell, Active Directory Get-object issue
I have been tasked to create a list of members of a custom object/custom attribute in Active Directory. I felt the best way to do so is use PowerShell. I can list the objects in a specific OU, but I ...
0
votes
0
answers
252
views
C# API Get Request with Basic Authentication - Server is Returning (403) Forbidden
I'm attempting to make a connection to an API endpoint. I'm getting (403) Forbidden. I was hoping someone could help me figure out what I'm doing wrong with this. Here's my code:
using System;
using ...
0
votes
1
answer
131
views
Nagios BAT file not returning correct status code
I've written a batch file for a Windows server to detect whether a particular service is running and if it isn't, return a Critical status back to Nagios. The script works perfectly (as in, it can ...