Programming in an Interpreted language executed by a running Shell

learn more… | top users | synonyms

-2
votes
0answers
11 views

script to scan through all the users' home directories and purge .log or .txt files not used in past “n” days

I need to write one korn shell script to scan through all the users' home directories and purge .log or .txt files that have not been modified in past "n" days for . If it can display top 20 users ...
1
vote
0answers
11 views

Trying to get pid from a script running as su -c

I am trying to get these scripts to work in an environment where the java application needs to run as user foobar no matter if it is started as root or foobar. So these are my modifications to the ...
0
votes
0answers
19 views

How to pipe output from cat to cut [migrated]

I want to cat /proc/uptime into cut -f1 in a Bash script. I've tried; cat /proc/uptime | cut -f1 cat /proc/uptime > cut -f1 cut -f1 < cat /proc/uptime Do I need to use echo or something ...
0
votes
1answer
43 views

What are the best ways to monitor and report disk usage on solaris?

df and du provides a total view of usage but the problem with these is that they are not broken down per user. Is there a tool that does this? I found quot but that only works on ufs. Is there an ...
-1
votes
4answers
41 views

Check if remote mysql is running

I want a bash shell script that i can run using a cron job to check if mysql on a remote server is running. If it is, then do nothing, other start the server. The cronjob will be checking the remote ...
0
votes
2answers
54 views

#!/usr/bin/expect not working

This is probably an easy question, however have a simple expect script that I've add the executable bit to that seems to be ignoring the #!/usr/bin/expect interpreter line. Further more, it also ...
0
votes
1answer
15 views

how to put tabulator as parameter for sudo in sudoers file

I would like to give for specific user allowing to put tabulator as parameter to program. Full invoking looks like: sudo /sbin/vgs --units b --nosuffix --noheadings --separator 'TAB' I try to put ...
0
votes
0answers
12 views

expect: does “” (spawn_id exp70) match glob pattern [migrated]

I have written an expect script that works perfect for testing passwords on our network until it has looped through my list quite a bit, then the debug output shows that there is nothing to match. ...
0
votes
1answer
33 views

Using curl with cookies

I hope someone can help me out on this one. I have been trying this for a while now, with all sorts of variations and cannot seem to get this to work. I am trying to script a way to log in to ...
0
votes
0answers
35 views

Error with a specific bash script

I must first of all shamefully admit that I unfortunately know nothing about scripts... I am simply trying to use one that seems to fit my goal. I am running a VPS node with OpenVZ, and I need a ...
1
vote
0answers
37 views

Echo each shell script command with a timestamp

set -x or set -v prints every executed command. How do I get the command printed with the time when the command started executing?
1
vote
2answers
84 views

Special char or wildcard in awk field separator

Would appreciate to know about the special char or wildcard in the following command: /sbin/ifconfig eth0 | awk -F ' *|:' '/inet addr/{print $4}' What does the code below mean? awk -F ' *|:' '
0
votes
0answers
34 views

Debian: passwd command not found [duplicate]

I don't know why, and what's the resolution, but on my Debian I have this problem: root@server:~# passwd -bash: passwd: command not found How can I resolve this ? I had same problem with shutdown ...
1
vote
1answer
48 views

Bash Script to set Linux OS

I'm working on a bash script and ran into an issue. I'm pushing what I know from using normal if/fi statements and trying to use them to set variables related to picking up the OS version, such as RH ...
1
vote
0answers
35 views

Gitlab custom hook issues

I am implementing a custom gitlab hook. While some one pushes in master, I want to update a specific file. Then commit this change and push it to remote origin. The hook looks like below: ...
-1
votes
1answer
95 views

How to run a shell script on all amazon ec2 instances that are part of a autoscaling group?

Can anyone please tell me how to run a shell script on all the ec2 instances that are part of a auto scaling group. The scenario is that i have a script that i want to run on many ec2 instances that ...
1
vote
2answers
147 views

password check in bash script calling on expect

Background: I have to copy a file from one server, to over 100 servers in a test environment. once the file is copied, it requires to have the permissions on the file changed/verified. These are all ...
0
votes
1answer
50 views

Export or Forward /var/spool/mail/USER (readable for customer)

there are some bounce mails in the /var/spool/mail/USER directory that failed to send. Now the customer receives all of those mails from us because he does not have direct access to them. I can ...
1
vote
1answer
90 views

What does a minus sign inside of dollar brackets of a shell script mean?

In an existing shell script, I'm seeing some variables referenced that either include or end with a minus sign. For example: PID=${PID-/run/unicorn.pid} and: run_by_init() { ([ "${previous-}" ...
0
votes
1answer
91 views

Bash linux increment variable

i am trying to increment a variable name inside a for loop to get 4 dynamic variable in each loop, this is an example while read line do for n in `seq 1 4` do ...
0
votes
2answers
65 views

Can I get an array as an option argument in bash script

I am writing a shell script and wants to pass multiple options in an argument. Is it possible to do that like using getopts? Requirement example: ./shell.sh -d db1 db2 should pass the values db1 ...
-1
votes
1answer
116 views

Bash FTP login into Microsoft FTP Service, Invalid command

This is my script. As you can see it executes only 1 command (cd /) after connecting to a remote FTP server. It's very simple... but it doesn't work and give me "Invalid command". I don't understand ...
0
votes
2answers
79 views

Bash scripting: Using wildcard

I have two different folders. The first one contains symlbolic links named with the names of my servers (for example: udcedpai101). The second one contains the inventory of my servers where the ...
0
votes
0answers
222 views

OpenVPN Server client-connect scripts aren't executed

I have an OpenVPN server up and running that (Windows) clients can successfully connect to. Now I'd like to share a luks encrypted partition with those clients. The goal is, that the server fetches ...
0
votes
2answers
70 views

using powershell ; from a given location a of folder i want to validate and show the number of specific filetypes respective folder

Using powershell from a given location a of folder I want to validate and show the number of specific filetypes respective folder. I tried using the command to count the number of files in a folder I ...
0
votes
1answer
48 views

Why is my shell command not working?

I have a shell script that I'm working on that uses pssh to get the user id of a user on a remote server: for USER in $(cat users.txt); do runuser -l mike -c 'pssh -H server.mike.com -o ...
0
votes
1answer
55 views

Issue with Bash Script On FreeBSD

I have the below bash script set to run every hour via cron as the root user. The purpose of this script is to email us when files have been uploaded to our sftp server and send us the logins. Here is ...
0
votes
1answer
140 views

How to automate input for a repetitive script! Expect in Bash?

I am a junior sys admin. Reason I'm asking this question is because we don't have a senior sys-admin here who is proficient with scripting. Senior guys are at the head office and too busy for ...
0
votes
1answer
127 views

Bash: Output of a command is written only to screen and not to another file while using tee, what could be the reason?

In order to troubleshoot some ftp connection error, I've been instructed to write a bash script which will infinitely connect to a remote frp server and get one file from there. ftpuser="ftpuser" ...
1
vote
0answers
57 views

Linux: What could be the reason for random fails in updating passwd.byuid by running yppasswd?

In order to allow NOC users in my company to manage users through NIS I've created the following script: #!/bin/bash # This script will simplicate NIS user management. # You will not be able to ...
0
votes
1answer
264 views

Executing command remotely on another linux server from a shell script

I have a shell-script which extract details from a log file between two dates and executes a command on the output to generate some report.The log files are on different server and scripts are ...
1
vote
0answers
89 views

How to package shell script file with license key file

I am working on automated shell script for specific task . Before executing task steps I want to validate the license key provided to the customer with a webservice call. Please help me in making ...
0
votes
0answers
27 views

rdesktop to a ec2 instance: why does not -s work?

I'm trying to connect to a windows ec2 instance and execute a script from linux shell. I'm able to start an rdp session with rdesktop (windows desktop opens on my pc), but no matter what command I try ...
0
votes
1answer
97 views

Command fails during script execution in bash

I'm working on a bash script for automatize some common tasks but I'm having some issues and I need some help. This is the script I'm talking about: #!/usr/bin/env bash PS3='Please enter your ...
0
votes
1answer
69 views

Creating enterprise init script (to support all Linux distros)

I'd like to create my own init script to make my program start at boot and be controlled via "service" utility in most popular Linux distributions. Requirements: it should be portable across ...
0
votes
3answers
96 views

How can a script loop for 30 days?

I have a script, backup.sh, that creates a backup of a MySQL database and then SCPs it to a remote server. This works great, and I can run this once per day using crontab with no problems. However, ...
2
votes
2answers
94 views

Looking for a way to wrap a command and give its own shell

I am working with the command line executing the same commands many times manually following the same pattern. Now I am looking for a way to simplify it by just typing the command only once. Lets ...
-3
votes
1answer
117 views

Are these Advanced Features possible with a Bash Script on an Ubuntu Server? [closed]

I am trying to build a really flexible and useful Server Backup Bash Script. I have pretty much no experience working or building Bash scripts. I know that thousands of them exist in the wild but I ...
-7
votes
1answer
71 views

Trying to understand linux script [closed]

I have this Linux script I found and I'm trying to understand it. Could someone please help me to understand it. The script if [ ! -d "/home/ftp/$PAM_USER" ]; then /bin/su - ftp -s /bin/sh -c ...
0
votes
2answers
113 views

Creating a log file inside a script works when manually run, but not when run through cron

I'm using Percona's Xtrabackup tools to back up a database nightly. I wrote a wrapper script to keep the proper number of backups around, write the output to a log file, and email the log file if the ...
0
votes
1answer
94 views

124 emails sent at once while one should be sent every five minutes by cron if a certain web service stops running

So I set up a simple script to send an email alert when a certain web service stops running. It has a simple flow of: test = $( curl [address] | grep [a certain string in response] | wc -l ) if [ ...
3
votes
1answer
314 views

How to schedule a Cron job for the second to the last day of each month

I want to schedule a task for the second to the last day of each month. I have read this great article about shell scripting the execution. I have also seen that you can use "L" to represent the last ...
0
votes
1answer
79 views

Why is permission denied during pssh?

I am trying to add an ssh public key to a bunch of servers authorized_keys file. My thought was to use pssh and a list of hosts. To test, I tried to pssh to one host: pssh -i -H root@host echo ...
-4
votes
2answers
59 views

What does this shell script mean? [closed]

#!/bin/bash /usr/sbin/ntpdate ntp.jst.mfeed.ad.jp I found such a script file,maybe it is used to confirm the time, can you explain it in detail?
1
vote
0answers
110 views

Running inotifywait on startup of machine

I want to start this inotifywait script on startup of the machine, in order to monitor the folders from the moment of booting: #!/bin/bash while inotifywait -r -e ...
4
votes
1answer
51 views

Script does not run under Domain Administrator

Server running 2003R2. I have a script, which basically sets a variable, which then uses it to name a backup file. I have given the exact script here: echo > "%temp%\tmp.vbs" wscript.echo 10000 ...
1
vote
1answer
60 views

SSH issues: keyfile and host file not working as expected

When I login to server with a key ssh -i /home/me/.ssh/id_rsa server everything goes without glitch. The key is authorized on the server. However if I try to do same from a shell script, I get a ...
-2
votes
1answer
374 views

How to insert text from a file into another in bash [closed]

The content in fileA is: Here’s the ip list. ip: 2.2.3.4 ip: 2.2.3.5 ip: 2.2.3.6 ip: 2.2.3.7 The content is fileB is ip: 1.2.3.4 ip: 1.2.3.5 ip: 1.2.3.6 ip: 1.2.3.7 How to use sed command or ...
1
vote
2answers
344 views

Executing local function code on a remote server

I am updating about 20 bash scripts that perform various server-side operational tasks, checking status / sending reports etc. On some environments these scripts will run locally, on others they need ...
0
votes
0answers
27 views

find running ec2 instances and compare with tag like “linux” running instances or get mail whose running without tag. vai shell script

with help of code: Array3=ec2-describe-instances | grep INSTANCE | grep running | awk '{print $2,$5,$9,$10}' Array2=ec2-describe-tags --filter "resource-type=instance" --filter "key=linux" | awk ...