Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

Generic programming in an Interpreted language (as opposed to compiled) executed by a running Shell. Sometimes referred to as "Glue Code" due to the practice of managing the execution and output of one or more compiled binaries and passing said output to another series of commands.

621 questions
0
votes
2 answers

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.com.zone"; }; The command: sed -nie…
Theo Orphanos
  • 133
  • 1
  • 10
0
votes
1 answer

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 following error: -bash: my_script: command not…
Roy Hinkley
  • 527
  • 4
  • 13
  • 20
0
votes
2 answers

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 ~C escape sequence, like: [root@host ~]# [root@host ~]# ssh> !ip ad Now, I would love to be…
Adam V
  • 188
  • 1
  • 10
0
votes
4 answers

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 be eval'd correctly on each server. Here's my…
Ryan
  • 420
  • 2
  • 8
  • 16
0
votes
1 answer

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 number of years, and instead of using say find I…
Cesar
  • 103
  • 2
0
votes
1 answer

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 and time and type of files is text(.txt). Files…
Florentina
  • 1
  • 1
  • 1
0
votes
2 answers

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 would change with different path value as…
umesh
  • 1
0
votes
1 answer

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 script. expect << EOF spawn sftp -oPort=23…
Teja R
  • 3
  • 3
0
votes
1 answer

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 collects only picks the last line and I do not know…
0
votes
1 answer

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 it at the same host,runs perfectly,outputs to…
selman
  • 103
  • 3
0
votes
1 answer

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 \"CREATE DATABASE graphite WITH OWNER graphite\""…
jango
  • 59
  • 2
  • 3
  • 12
0
votes
1 answer

getting multiple issues while creating a scrip to update hostnames in /etc/hosts file?

I'm completely new to the scripts and hence need help to fix this. We've around 3000 VMs & 450 Physical servers which are Linux based servers (few of then ubuntu starting from 9.x & few of them are Susu starting 8.X & majority of them are RHEL…
Hrish
  • 87
  • 1
  • 8
0
votes
2 answers

Exit code for ldap testing using nc or ncat

I am trying to write shell script to test if a server is able to reach a specified ip and port. The commands i am using: ncat -w 5 636 or 389 > /dev/null 2>&1 < /dev/null | echo $? The issue is when i check for an exit code for the above two…
Jigar P
  • 1
  • 1
  • 1
0
votes
1 answer

Close ssh session at the end of bash script

In the .profile of each user of the system (debian 8), I call a script who start a typescript session, to log everything in a file: #!/bin/bash script -f $HOME/.log/$(date +"%d-%b-%y_%H-%M-%S")_shell.log The thing is when you enter "exit" then,…
poka
  • 135
  • 3
  • 13
0
votes
0 answers

Crontab is not running in ubuntu 14.04

I want to do database back. I have created two files one is '.sh' and another one is '.py' file. both have execution permission. -rwxrwxr-x 1 acespritech-bhaviraj acespritech-bhaviraj 152 Aug 8 14:26 google_drive_v8_backup.sh -rwxrwxr-x 1…