Questions tagged [bash]
Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).
3,559
questions
1
vote
2
answers
2k
views
ssh publikkey authentication for git within a bash script?
I currently have a bash script running on my Linux server that once a week goes through my repositories, performs some tasks, and backs them up remotely.
Today I started backing up some remote ...
1
vote
3
answers
3k
views
mass mv using find?
there are a bunch of filename.gif scattered in /home/ directories. I want all the filename.gif replaced by a /home/shared/filename_default.gif.
I tried something like
find /home/ -name "filename.gif"...
1
vote
3
answers
1k
views
Why does bash invocation differ on AIX when using telnet vs ssh
I am using an AIX 5.3 server with a .bashrc file set up to echo "Executing bashrc." When I log in to the server using ssh and run:
bash -c ls
I get:
Executing bashrc
.
..
etc....
However, when I ...
1
vote
3
answers
904
views
getting interface names from dmesg lines
I have some lines like
[ 17.440000] eth0: XYZCOMPANY ABC4353 802.11 Wireless Controller
[ 17.540000] eth1: XYZCOMPANY ABC4353 802.11 Wireless Controller
[ 17.640000] eth2: XYZCOMPANY ABC4353 ...
1
vote
4
answers
2k
views
Fix a tomcat6 error message "/bin/bash already running" when starting tomcat?
I have a Ubuntu 10.04 machine that has tomcat6 on it. When I start tomcat6 with /etc/init.d/tomcat6 start I get
* Starting Tomcat servlet engine tomcat6
/bin/bash already running.
and the server ...
1
vote
2
answers
1k
views
Multiple Users use Script to Access Remote Server via Passwordless SSH
I am currently setting up a linux box that is tied into Active Directory. This box will allow users to SSH into it with their AD username and password to gather information (Box A). The issue is I ...
1
vote
5
answers
4k
views
How to execute with /bin/false shell
I am trying to setup per-user fastcgi scripts that will run each on a different port and with a different user. Here is example of my script:
#!/bin/bash
BIND=127.0.0.1:9001
USER=user
...
1
vote
1
answer
790
views
mac cron can't use the shell correctly
I've set up cron to run a simple hello world shell script, but it's giving me an error that Google isn't helping me resolve. I've got to be missing something really simple!
Here's my crontab:
MAILTO=...
1
vote
2
answers
1k
views
Will the background process exit when you log out in linux?
[root@~]# ./file.sh &
I don't know if $! will terminate if I just log out immediately?
1
vote
1
answer
409
views
Linux / Sendmail one liner having trouble with large directories
For whatever reason, spammers found a way to relay mail through a side-system. The exploit has already been addressed.
The problem is that I had massive amount of emails in my /var/spool/mqueue ...
1
vote
2
answers
4k
views
How to execute a bash shell script via a browser link
I have written a bash script that periodically checks a directory for newly added .ear files and copies them to the respective JBoss server's deploy directory.Before copying, it checks if JBoss is ...
1
vote
1
answer
4k
views
Delete files older than X days from remote FTP server [duplicate]
My backups are stored on remote FTP server. I'm looking for a universal way to clean-up the FTP directory using bash or python.
Any help would be appreciated.
Edited:
I have only FTP access to the ...
1
vote
3
answers
2k
views
mysql create database and user script
Question Rewritten:
HOMEDIR="ftpuser"
REMOTEIP="1.1.1.1"
MYSQLPASS="password"
Q1="DROP USER "$HOMEDIR"_shop;"
Q2="DROP DATABASE "$HOMEDIR"_shop;"
Q3="CREATE DATABASE IF NOT EXISTS "$HOMEDIR"_shop;"
...
1
vote
1
answer
1k
views
running bash script as root with hardcoded password
Most probably this has already been answered in other threads, but I can't find the exact solution.
I need to call a bash script via a php script which (bash) changes system time. I need to run that ...
1
vote
5
answers
7k
views
I have serious problem "-bash: /bin/egrep: cannot execute binary file"
I have serious problem when I loged in to my server (Centos5.2-Final)
It announced that :
-bash: /bin/egrep: cannot execute binary file
-bash: /bin/egrep: cannot execute binary file
-bash: /bin/egrep:...
1
vote
3
answers
3k
views
Expect script does not print (cat ) a file on remote server
I have an expect script which checks if a file exists on a remote server and then tries to print ( using cat) it if it does
For some reason the expect script ignores these commands.
send "if {[file ...
1
vote
2
answers
978
views
executing a service after another service has been started
i have installed MySQL NDB cluster. It needs around 2-3 minutes to synchronise the database in between cluster nodes. Once the synchronisation finished only, I can start another application called ...
1
vote
6
answers
2k
views
SSH and redirection
Consider the following command:
ssh aristotle sudo /bin/sh < test.sh
I want the redirection to apply to /bin/sh but it is consumed by sudo. Any ideas on how to achieve what I want?
1
vote
1
answer
215
views
HEREDOC in Dockerfile produces no output
I have this command that I am trying to run in a Dockerfile and it is producing no output to the file:
FROM alpine:3.19 as base
RUN <<-EOF > /root/.npmrc
registry=https://\${...
1
vote
1
answer
174
views
why does systemd tag my self-made service "thawing" after running it for a few days?
I have found the strange tag of "thawing" running my self-made service using systemctl status XXX like this:
On the contrary, I found it running several threads via htop:
At first I ...
1
vote
1
answer
560
views
Calculate seconds minutes and days ago in shell
I have a timestamp that saves a user's last access information like
Time => 14:15:05 PM
Day => 08/23/2023
Based on this saved information, I would like to write a command that returns how much ...
1
vote
1
answer
896
views
Dump a Table from MySQL Database directly from sql server using bash
How can I dump a table from a MySQL database using a bash script?
Like we can use the below command to dump a table
mysql -u username -p database_name > file.sql
But how can I dump only a single ...
1
vote
1
answer
542
views
bash change directory with spaces and backslash
I'm trying to build a script that I need to be quite able to manage directory with spaces or/and backslashes in their name or not.
Inside a bash script or directly on bash shell using variables for ...
1
vote
1
answer
311
views
how to exclude folders by date with find?
This is "myfolder":
tree -a 'myfolder'
myfolder
├── 20220902
│ ├── filefoo
│ └── filebar
├── 20221001
│ ├── filefoo
│ └── filebar
└── 20221015
├── filefoo
├── filebar
└── ...
1
vote
1
answer
76
views
how to extract values from files, compare it with a variable and send to out file
I have myfolder with this files:
ls myfolder
filefoo filebar filefoobar
For example, the content of filefoo is:
total: 379400041
cache_object://localhost/active_requests 379400041 6778 0-...
1
vote
1
answer
4k
views
How to automate aws cli commands with shell script
I wonder anyone can help me with making a shell script which automate aws cli process for:
1.Creating Security group
2.Set roles to this Security group port 22 and port 80
3.Create a ec2 instance with ...
1
vote
1
answer
685
views
Is there a faster implementation of uuidgen from bash?
I am using a bash script and using the command uuidgen to generate UUIDs. However it is quite slow when invoked in a loop. Are there any alternatives I can invoke directly from bash?
I'm guessing the ...
1
vote
2
answers
1k
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 &...
1
vote
1
answer
785
views
SSH'ing into WIN 10
People of the Server-verse, a humble hello from fellow apprentice.
Above line goes out to show i am a newbie and thus need help with trivial probs, so appreciate all help in advance.
I am facing 2 ...
1
vote
2
answers
9k
views
How to use wget http status codes in an if else statement to take an action based on the status code
I'm writing a script that is downloading a bunch of files, I'm using wget to download the file and I want to echo back to the terminal custom status messages for each file based on 3 scenarios:
...
1
vote
1
answer
2k
views
Environment Variable Empty in Bash Script
I have an EC2 instance that I am deploying on AWS.
I am using an Amazon Linux 2, and I am passing a user data to it as such:
userdata_file.write(
f'''
#!/bin/bash\n
export ...
1
vote
1
answer
863
views
rsync : write failed - No space left on device (28) despite using --inplace
I am using a script to make a backup of a running Debian Stretch based Linux Distro (NextCloudPi)
The method in the script that does the backup uses rsync.
backup()
{
mntimg
sync
rsync -aDH --...
1
vote
1
answer
520
views
How to get extra vars java link and download it in ansible and extract it
I want to download java from http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
then extract it
tar -xzvf jdk-8u131-linux-x64.tar.gz
but ...
1
vote
1
answer
216
views
How to delete the grepped iptables
I have iptables starting from cali-
root@Ubuntu-18-VM:~# iptables -S | grep -oP '(?<!^:)cali-[^ ]+'
cali-FORWARD
cali-INPUT
cali-OUTPUT
cali-cidr-block
cali-from-hep-forward
...
1
vote
2
answers
1k
views
CENTOS apache ALL=(root) NOPASSWD: /path/to/shell.sh is not working
Trying to do a web interface IPtables management.
Created a file test.php
$output = shell_exec('sudo bash /usr/bin/iptables.sh 2>&1');
echo $output;
Gave /usr/bin/iptables.sh NOPASSWD so I can ...
1
vote
2
answers
1k
views
lxc send file or copy
I am trying to copy a file with lxc, now I am already desperate. Here are some commands that I have tried:
#temp=$(cat 2.sh)
#lxc-attach -n containerName echo $temp > /root/2.sh
#lxc-attach -n ...
1
vote
1
answer
82
views
How to connect from Ubuntu VM on Azure to another without uploading the private key
My Topology
Two Ubuntu servers, the edge which is exposed to the internet, and the core which is only connected locally. Both are on the same subnet and the core only accepts SSH from the edge server. ...
1
vote
1
answer
37
views
Bash-Skript (Cronjob): Programm öffnen hat falsche Sprache
Which ENV must be exported that a bash cronjob script opens the program in the correct language?
If I open the bash script so manually in the command-line the program is opened in the correct language....
1
vote
1
answer
6k
views
How to automate ssh password Windows / Git bash - already with the installed software without needing to install
I have a VM that has the fixed snapshot, and I have not the right to install anything
How I can achieve the goal?
Passing password to ssh connection Windows 10, using git bash without needing to ...
1
vote
2
answers
650
views
How to use expect command with .run program in replace for yes command
The program.run I'm trying to run:
Asks 2 questions that need the answer "y"
Asks a third question at the end which is "press any key to exit"
In addition, it doesn't have the &...
1
vote
1
answer
595
views
Initramfs - Set hostname from custom initrd script
In our company, I'm creating an Ubuntu Autoinstaller (v. 20.04). For some company reasons, its required modify initramfs. (initrd file).
I'm created a script, and added a link to init file in main ...
1
vote
1
answer
556
views
tail -F still stops on logrotate sometimes
Linux ip-10-10-64-122 4.1.7-15.23.amzn1.x86_64 #1 SMP Mon Sep 14
23:20:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
I'm using tail -F in a bash script which in turn loops over the results. This script ...
1
vote
1
answer
112
views
Misaligned AWK output
I have simple awk command generating output and then sending an email:
awk '(NR==FNR){a[$2]=sprintf("%.2f",$1*value); next} {print $1,$2,a[$2]}' OFS="\t\t\t" value=$COST /tmp/1.txt ...
1
vote
1
answer
171
views
Hotstrings on a bash console
I can do things like this to alias often used things alias iii='sudo yum install' and that works fine, but it's nice to be able to expand a command on the command line as I use it. For sure I can type ...
1
vote
3
answers
2k
views
SSH from A through B to C, using IdentityFile on A
I've see some similar questions but without a clear way forward, if this was already answered before please close this one.
My scenario is:
Host C is not accessible from A.
Host B is accessible from ...
1
vote
1
answer
1k
views
Run local bash script on multiple remote machine
I have below bash script,every time i want to create a user i need to copy this script to server and run it.
Is there any thing we can do so that this script fetches the IP's from a hosts.txt file(...
1
vote
1
answer
142
views
moreutils chronic - append full output to logfile?
chronic, which is part of moreutils, is a great tool for selective failure-only email notification of cron tasks:
chronic runs a command, and arranges for its standard out and standard
error to only ...
1
vote
1
answer
950
views
cron not running bash commands
I am using the whenever gem to generate cron commands. I can check these commands with crontab -l. The generated commands are
24 15 * * * /bin/bash -l -c 'cd /Users/Chris/Sites/covid_tracker &&...
1
vote
2
answers
14k
views
Running a bash script from Putty on a remote server
I was advised to post here after my question was closed on Stack Overflow.
I'm trying to run a bash script on a remote server using Putty over SSH. I'm on a Windows 10 machine and the script is saved ...
1
vote
1
answer
7k
views
MYSQL Start unit not found
Im using AWS Linux 2 AMI
Currently I have AWS EC2
Recently the mysql doesn't work anymore but it worked before.
when I tried to do this
sudo service mysql start
or
sudo service mysqld start
It ...