Questions tagged [scripting]
A form of computer programming that — in the context of system administration — lends it self well to automating tasks.
1,829
questions
0
votes
0
answers
11
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
0
answers
35
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 ...
-1
votes
0
answers
16
views
Recursively xv compress each file in multiple subdirectories?
I have multiple directories and subdirectories, with files inside.
I would like to recursively compress each file in these (sub)directories with xv (xz -9ze -T0) which are not .xv files yet, without ...
0
votes
1
answer
33
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
29
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
66
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
45
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
31
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
27
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
37
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
116
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
384
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
68
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
80
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
358
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
1k
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
45
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
46
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: ...
2
votes
1
answer
129
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
63
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
447
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
550
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
105
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
300
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
82
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
412
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
334
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 ...
0
votes
0
answers
64
views
How to convert text in except script?
I'm trying to create a script that will answer questions in my other script on perl. There are simple actions but I cannot figure out how to make except understand the output.
Here's my code:
#!/usr/...
1
vote
1
answer
34
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
77
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 ...
0
votes
0
answers
64
views
Assign an AD Group Read only Permission to Multiple User Home Drive Folders using CSV list
I'm trying to put together a script to perform the following task:
First to add an AD Security Group named "ADMigration" and assign it (Read access) to a large list of User Home Drives (...
1
vote
1
answer
373
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
164
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
547
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”
#
...
0
votes
0
answers
20
views
PHP way to show a page depending of user PC or mobile?
i have 2 versions of a page, PC and mobile, how do a show one or other depending on User Agent?
I know that using INCLUDE but i'm a little confused so maybe a example can help me.
TY
1
vote
1
answer
275
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
48
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
569
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
2k
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
332
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
220
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
114
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 ...
1
vote
1
answer
701
views
Linux script , Incremental backup in the same server
Could you please someone guide for the below incremental backup script, i have already written the script. I am facing an issue while looping the script.
Requirement i need : Consider a source folder ...
1
vote
0
answers
180
views
How can I escape the "|" in file names in a bash script?
I have a list of files in the Linux file system. Some of them contains a "|" in the names.
How can I escape the "|" in a bash script to perform file operation (copy, move) in the ...
1
vote
2
answers
476
views
Bash script to configure IPTABLES
I am beginner at BASH scripting, I'm trying to write script to configure iptables but it seems something wrong in the first block, Please advise
#!/bin/bash
echo "IPTABLE ASSIGNMEN"
echo -e &...