Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

0
votes
1answer
13 views

detect network status even if it is disconnected for a millisecond shell script

I have this shell script which keeps running continously. #!/bin/sh while true; do ping -c1 www.google.com > /dev/null; done When I disconnect my lan cable this script throws error in the ...
0
votes
0answers
16 views

Error while running shell script, Please check the error generated below

Can someone help me what's wrong with below script. START=$(date +%s) Sta="2 4 8 10 20 40 60 80 100 150 200 250 300 300 400 450 500" for staNodes in $Sta do ./waf --run "scratch/freeze-count --...
0
votes
1answer
44 views

How to start a jar file using systemd

I want to start java application on system boot using systemd. I tried to do by adding above scripts. But service is not starting. my-startup.service [Unit] Description=Startup [Service] ExecStart=...
1
vote
1answer
49 views

shell script to list directories in decreasing order of disk usage

I am looking for a shell script for Ubuntu Server that lists the disk usage of directories in a decreasing order. It should not list subfolders (recursively). The behaviour should be similar to the ...
0
votes
0answers
43 views

Run none Linux command in shell script

I am running the following code to telnet to a server via a shell script. #!/bin/sh (echo myusername; echo mypassword ; cat) | telnet -l myusername 127.0.0.1 After successful login, my shell changes ...
0
votes
1answer
37 views

How can I compute only current instance disks

I need some help with Google cloud. I need a shell script for creating a current instance snapshot. I have researched and found some shell script which can create snapshots for all project instances, ...
3
votes
1answer
48 views

Why is eval not working with command substitution?

I have this command $("${DIR}/test.py" "$1") the output of which is export SOME_VAR="hello world" export ANOTHER_VAR="hello" But eval $("${DIR}/test.py" "$1") seems to do nothing. What am I ...
5
votes
1answer
238 views

Closing All Shared Files on the Network [duplicate]

I am trying to close all of the open files in the shared folders of a server via PowerShell script. I found the following script which only close files on one drive (F:), however, this server has 3 ...
0
votes
1answer
16 views

Prefixing iostat with the current time

I'd like to prefix my iostat output for device sda with a timestamp. Y-m-d H:M:S would suffice. This does not seem so straightforward however. My first attempt was simply: # vi just_echo ...
0
votes
0answers
36 views

Logstash monitoring: Verify status of pipelines

Trying to establish monitoring for http://elasticsearchnodeexample.com:9600/_node/stats/pipelines to verify status of 2 pipelines Output : "pipelines": { "pipeline1": { "events": { ...
0
votes
3answers
255 views

Allowing SSH To use ssh-agent in bash script

I am working on recon for a set of systems my company is taking over and they use a different authentication method than we do. Specifically we use AD auth and a jump server to access systems where ...
-1
votes
1answer
31 views

How to remove some character from a string in Unix?

I have two string like this a=[2018:09:11-18:37:06:376476] b=[2018:09:11-18:37:06:376446] I want two string like a= 20180911183706376476 b= 20180911183706376446 Can Anyone please help me out?
0
votes
1answer
37 views

How to replace some character from a string in UNIX? [closed]

I have two string like this... a=[2018:08:22-15:26:18:26182619] b=[2018:08:22-15:26:18:26182619] And I want to convert a= 20180911183706376476 b= 2018082215261826182619 Can anyone please help me ...
0
votes
1answer
452 views

Jenkins - environment variable not setting up from pipeline

Here is my script. Im trying to set up variables in pipline shell script: node { anyconnect = docker.image('anyconnect:1').run("--cap-add NET_ADMIN --cap-add SYS_ADMIN --device /dev/net/tun:/dev/...
0
votes
2answers
34 views

How to print true if condition in shell script

I'm writing a script to change few setting according to location and to do this i selected hostname as a benchmark. My aim is, if my hostname condition comes true then do this. For this i'm writing a ...
0
votes
1answer
52 views

Defining array in shell script

I am trying to define array in my shell script which would have content like below cassandra_hosts=(cassandra1.test-dev.local cassandra2.test-dev.local cassandra3.test-dev.local) But it doesn't let ...
0
votes
0answers
119 views

sed + delete duplicate lines except the first one according to specific request

in /etc/services file I can see duplicate lines for example the following line is duplicate ( or more ) odasrv 2432/udp so it can easily deleted by sed as the follwing sed -i '/codasrv ...
0
votes
1answer
99 views

Grep returns nothing

This is the grep command I used grep -ic address log* The output is 0. I know for a fact that there are more than 60 occurrences of the word address in the log file. But I still get 0. Now, I ...
0
votes
2answers
184 views

GCP Instance startup script error

Trying to add a startup script following the sample here: https://cloud.google.com/compute/docs/startupscript The instance is created with no problems but the script does not execute. Console shows ...
0
votes
0answers
67 views

Pass shell script to cygwin ssh from mac with arguments

How can I run a shell script from mac on a Windows openssh installation and pass arguments? This is what I currently have: ( cat run.sh ) | ssh -t user@host How can I modify this to pass arguments ...
0
votes
1answer
77 views

Shell script popup with sound

I have a shell script running in crontab to perform certain checks. In case of any problem I want to alert user. For that purpose I am using zenity and play command zenity --error --text='Something ...
0
votes
1answer
470 views

Power shell script Get-ADGroup member and owner

I'm having some problems with my powershell script to get ADGroups from our AD. I want the information about what the group name, description of the group, members in the groups and the owner of the ...
0
votes
0answers
23 views

Want to see all the changes happned to aws environment during last one month

I Want to find a way to see all the changes happened to My AWS environment in past one month (changes to all resources), need it in report or dashboard kind, Ex:- AWS IAM(change in role, added ...
2
votes
1answer
2k views

powershell script get-ADGroup and get-ADGroupmember

I have a problem trying to "fix" a PS script I got from a collegue to get me information from a customers AD. I'm trying to get a list of all distrobution mailboxes and members of these. But the ...
-1
votes
3answers
1k views

Bash script: save last line output from terminal

I am writing a bash script in which I would like to save the output of the last command in to a variable before running my next one so I can display it later. I have tried a few different methods ...
-2
votes
2answers
75 views

Shell script to enumerate the (already existing) LDAP group called “VPN Users”

I am new to LDAP and learning about the ldapsearch and ldap in general. Would like to write a shell script that enumerate the (already existing) LDAP group "VPN Users", then get all user "...
-1
votes
1answer
140 views

How to pass variable into bash script and use seperate variables with awk?

I have a script that I am using to clear out all lines of a log files older than X days. X can be passed in via command line as well as the log file name, ex usage: ./purge-catalina.sh 3 /opt/...
1
vote
0answers
110 views

LAPS (local administrator password) command

Anyone knows if this is possible to change LAPS command so it sets permissions 1 user to 1 computer? The reason is I want to allow target user to be able to view his computer laps password. Currently, ...
0
votes
2answers
175 views

Delete a zone from named.conf with shell script

I am trying to delete an existing zone record from bind's named.conf file (on a centos 7 release). The zone record looks like that: zone "example.com" IN { type master; file "example....
3
votes
0answers
62 views

How to deploy a script to auto update google chrome on a lot of hp thin clients?

The hurdle is that the thin client wipes and re-images itself every night and I have no access to group policy. Any ideas of deployment or the most efficient way to do this? What I do have access to ...
0
votes
0answers
267 views

How do I script an unattended setup for MariaDB's mysql_secure_installation?

I found an answer on this for MySQL, but it doesn't seem to work for MariaDB: https://ubuntuforums.org/showthread.php?t=981801 I'd rather use debconf than the stdin based solutions from https://...
2
votes
2answers
72 views

`wget`-ting a website for “local” browsing on a different domain

I need to mirror a website and deploy the copy under a different domain name. The mirroring procedure should be all automatic, so that I can update the copy on a regular basis with cron. The mirror ...
0
votes
1answer
37 views

Shell script with executable permissions returns “command not found”

I have a shell script file with executable permissions: -rwxr-xr-x 1 root root 1147 Jan 26 2017 my_script Even running it as root - fully qualified (path/to/file/my_script) I get the ...
0
votes
2answers
529 views

Use bash script to send commands to SSH client?

Good Afternoon All, I recently became aware of my ability to send commands back to my local workstation from a remote SSH connection by using the <enter>~C escape sequence, like: [root@host ~]#...
0
votes
4answers
488 views

How can I run select commands on multiple servers from a shell script?

How can I execute scripts from arguments on multiple servers? I'm trying to build a command list, and then execute commands on each server. I'm unable to generate the command list in a way that can ...
0
votes
1answer
37 views

Log files in /YEAR/MONTH folder structure, how to delete old logs properly?

I have situation where we have log files being saved in a /YEAR/MONTH/ folder structure, e.g. /2018/03/fakelog.tmp.gz I'd like to have a cronjob run monthly to delete files older than a certain ...
0
votes
1answer
230 views

timestamp in shell code script

I'm new in shell coding and hopefully I'm in the right place to ask this question. I'm working with a shell script which collect daily file and send them via ftp. In the filename there are both date ...
0
votes
2answers
28 views

How to get the sub string part from a directory with shell command

I would need to extract only last 2 part from the following directory path using shell command "Android/2.1/Packages/test/debug/" Expected out put: /test/debug This path is the dynamic where it ...
0
votes
0answers
68 views

SSH Suspicious Commands on Hosting Server

I have a dedicated hosting server that is hosting few websites. I recently accessed my server thru Terminal command line and noticed that the last few commands that were executed weren't from me - ...
1
vote
2answers
69 views

Track User CPU usage for a period of time

I need to track amount of processes that a single user invoked and how much CPU-time (or % ) these processes consumed for a given period of time. The trick is that each of these processes normally ...
0
votes
1answer
235 views

How to use SFTP BatchMode inside EXPECT[Shell Script]

I have set of series SFTP commands which needs to run inside expect. But when i run the below script due to some reasons am not getting any output. Please correct me if am wrong any where inside the ...
-1
votes
1answer
163 views

bash + how to avoid specific messages in the log file

when I run the bash script on my Linux machine we get the following errors in my log , note - we set in the script: exec > $log 2>&1 , ( in order to send all standard error/output to $...
0
votes
1answer
171 views

Read all lines for .txt powershell

I have a PowerShell script that when I run it, create a local amdmistrator on the computers that I select and it gives me another txt in which they were created. But from the txt where the host ...
-1
votes
1answer
36 views

Remove lines from a file in between string

I have query if I can remove few lines from a file in between string. I have an example below: Eg: XML file. < String > Data1 Data2 Data2 < / String > I have a huge XML file in which I want to ...
0
votes
1answer
36 views

Linux Script command interpreting not working remotely

I have the below linux script(simplified): RUN_JAVA=$(which java) if [ -z $RUN_JAVA ] then echo "No Java found!" >> /tmp/output.txt else echo $RUN_JAVA >> /tmp/output.txt fi When I run ...
0
votes
0answers
21 views

Can't use assigned variables after command

I have the following script filename="network_list.txt" while read -r line do name="$line" ping_stat=$(ping -c 4 $name 2>&1) if [ $? -ne 0 ] then echo "...
1
vote
1answer
28 views

How to catch ssh enabled or not using Shell script for cisco switches?

I have a file of FQDN and I know how to check the ssh. I am using the following command: show ip ssh But I cannot do this manually, so I've decided to write a shell script. But I do not understand ...
7
votes
4answers
2k views

Loop through servers and run command

I have a set of servers mentioned in a text file called network_list.txt . How can i run through the servers and run command and display the result ? I have tried the follows : filename="network_list....
0
votes
1answer
116 views

how to insert postgres result to a shell variable

I want to set all this syntax in variable su -l postgres -c "psql -c \"CREATE DATABASE graphite WITH OWNER graphite\"" CREATE DATABASE so I wrote this res=$( su -l postgres -c "psql -c \"...
1
vote
0answers
23 views

how to avoid screen termination once the job is done [duplicate]

using a shell script i am ceating multiple screen in which i m running rsync cmnd with below syntax, n i m able to do so. screen -dmS "$SESSION_NAME" "$COMMAND" "$ARGUMENTS" but as soon as rsync ...