0
votes
0answers
29 views

Shell script permission denied despite +x flag [migrated]

This is an odd one, it only happens on one server (shared hosting, so I have limited access to configuration and logs), but I can't wrap my head around it. I have a shell script which runs some app's ...
1
vote
1answer
24 views

Losing carriage returns in variable assignment

If I assign a variable in Bash like so: PRIVATE_KEY="$(< ~/.ssh/id_rsa)" and then immediately dump that to a file: echo $PRIVATE_KEY > tmp.txt and then compare this to the original: diff ...
1
vote
2answers
76 views

Locked out after installing a bash without executable bit

After scp-ing a shellshock-patched bash binary to an openSUSE 12.2 Linux VM and replacing the login shell with it, no user can log in via ssh or the console. As it turned out, the executable bit got ...
1
vote
1answer
292 views

Shellshock protection in Rackspace Ubuntu

I am trying to update my Ubuntu 13.10 servers in Rackspace to avoid Shellshock bug, but it is not working. Here is what I am doing: $ sudo apt-get update && sudo apt-get install ...
0
votes
0answers
33 views

Cron bash script skips second do/done set

I have a script that checks IPs for ping reply then tries to run an snmpwalk on them. I am trying to schedule the script to run weekly in cron. When I run the script in the shell, it runs perfectly. ...
1
vote
0answers
53 views

Encrypting/Decrypting a file using openssl through an autorun script

So I am trying to encrypt/decrypt a file using openssl. I am running it through a script that is automatically run when I mount a USB, and decrypts the file. However, it doesn't work quite right, so ...
0
votes
1answer
48 views

insserv: warning: script 'uwsgi' missing LSB tags and overrides

This is my code: #!/bin/bash daemon="$APPVENV/bin/uwsgi" args="--emperor $APPCONF/uwsgi/app.ini" pid="$APPDIR/emperor.pid" case "\$1" in start) echo "Starting uwsgi" ...
0
votes
0answers
29 views

Bash and background processes PGID and receiving signals

My actual problem is that a process I run in an rcfile in docker as docker run container bash --rcfile rcfile remains attached to the bash session by sharing the PGID which means that when I Ctrl-C an ...
0
votes
0answers
35 views

How can I sudo su and change directory just after? [migrated]

I would like to create an alias that does something like this: alias userYYY='sudo su userYYY; cd /a/path/that/only/userYYY/has/access' So then from my command line, I am logged in with a sudoer ...
0
votes
1answer
17 views

Trouble using ssh-key gen specifying location and password

This is my code: ssh-keygen -t rsa -C "$APP" This works perfectly. However it then asks me to specify location and password. I was hoping I can automate this all in one go, however this command ...
0
votes
2answers
48 views

Generating random passwords with shell on server deployment

I'm trying to generate random and secure passwords to my various configuration files and settings on the fly when I run my automated deployment script. I want them to be generated, shown to the user, ...
0
votes
0answers
26 views

different interactive and non-interactive shells

A user account has it's shell defined in passwd file as bash. I would like to change this user account's shell to tcsh for non-interactive jobs (like ssh ), but keep interactive shell to bash. Is ...
0
votes
1answer
87 views

Where is this bash shell alias being configured?

While logged in as root onto a CentOS 6.5 system, I run ># alias alias cp='cp -i' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias ...
0
votes
2answers
392 views

Can't run AWS CLI from CRON (credentials)

Trying to run a simple AWS CLI backup script. It loops through lines in an include file, backs those paths up to S3, and dumps output to a log file. When I run this command directly, it runs without ...
2
votes
3answers
78 views

Can I use Bash interpreter in service/daemon scripts?

I'm writing a Debian/Ubuntu service that should start on at runlevel 2-5. Most of the existing services I came accross are written using /bin/sh (Shell) interpreter while /bin/bash (Bash) offer lot ...
0
votes
7answers
194 views

better way to loop through a list of servers

I regularly do things where I loop through a list of servers to take some action. For example: for s in `cat servers.txt` ; do echo; echo $s ssh $s 'do something' done I'm wondering (from a ...
0
votes
1answer
55 views

Bash function hangs while command run perfectly without function

Following function hangs : ssh() { local RESULTS; RESULTS=$(ssh $USERNAME@$SERVER $SSH_COMMAND1); echo $RESULTS; } ssh; while if i run following commands they work fine : ...
0
votes
0answers
19 views

Ctrl-C is ignored by pppd when put in a shell script

I'm trying to connect to GPRS network through a serial port connected GSM modem. When I call /usr/sbin/pppd call <peer_name> from the command line, It correctly receives and handles Ctrl+C from ...
3
votes
5answers
236 views

Hide the output of a shell command only on success?

Hiding the output of a shell command usually involves redirecting stderr and stdout. Is there any builtin facility or command which by default hides the output but on error dumps all the accumulated ...
8
votes
6answers
404 views

Find directories, where files with a specific ending are missing

I want to display all directories, that do not contain files with a specific file ending. Therefore I tried using the following code: find . -type d \! -exec test -e '{}/*.ENDING' \; -print In this ...
1
vote
3answers
83 views

locale-gen with purge does not work

I use the --purge option to remove existing locales before generating new one, but seems cannot remove existing locales? e.g. # locale-gen --purge en_US # locale -a C en_AG en_AU.utf8 en_BW.utf8 ...
0
votes
1answer
242 views

Shell script only executes partially when run with CRON [duplicate]

I've written a shell script that does the following: Retrieve mail from a POP3 account (using GetMail) Save a copy of that email to S3 (using AWS CLI) Email me the filesize of the email The ...
1
vote
1answer
114 views

Replacing LineFeed \x0a with SED

I have to delete lots of Linefeeds (Hex \x0a) in a logfile. I just have sed to solve the problem. It is a bit complicated I know.. Do you have idea how to solve the problem? Here is an example ...
0
votes
1answer
190 views

Disable the ability to hide bash command history

User can hide the command history in bash by either append a space before the command unset HISTFILE How to disable this?
0
votes
2answers
111 views

Gnu parallel not utilizing all the CPU

I have a simple python script that read from stdin (a single line), do some processing (string parsing, no IO involved) and output to stdout e.g. python parse.py < in.txt > out.txt I have an ...
8
votes
2answers
552 views

Symbolic link and sudo

I create a symbolic link: ln -s /tmp/folder1 /tmp/folder2 Then I go to /tmp/folder2 and run pwd: $ cd /tmp/folder2/ $ pwd /tmp/folder2 $ sudo pwd /tmp/folder1 # <-- This is the odd part Why ...
0
votes
2answers
39 views

Creating an environment variable for a specific user

When you set an environment variable in linux is it set only for the user who executes it, or can you specify a user when you store it, or instead is it always available for all users?
2
votes
1answer
172 views

Bash: two commands in dollar-parenthesis don't have same behavior

I don't undertsand why, in Bash: echo $(hostname --fqdn) works, echo $(id -un) doesn't (id: –un: No such user). Backticks give the same results. Is there some good practice for using this ...
0
votes
1answer
49 views

Trouble with $PATH on debian

I think I have a problem with $PATH. I am running a shell script and it is complaining that it doesnt recognize the command even though when I run it manually it does. Shell Script: #!/bin/bash # ...
1
vote
2answers
448 views

permission denied in running script

I am running a script but there is an unusual warning: This is what happened in my console #whoami root #ls -l test.sh -rwxr-xr-x. 1 root root 1894 Feb 2 01:58 test.sh* #./test.sh -bash: ./test.sh: ...
0
votes
1answer
70 views

Binary data in shell argument

Is there a way to safely encode / pass arguments to a shell command where the argument might be binary? I'm executing a command from within a PHP script that allows for user data. For security, ...
2
votes
4answers
240 views

Use logger in shell script

How can I use logger in a shell script? If I run ntpd -qnp pool.ntp.org 2> >(logger) in console, it works as expected. If I put it into a shell script #!/bin/sh ntpd -qnp pool.ntp.org ...
2
votes
3answers
194 views

How to parallelize the scp command?

I need to scp the files from machineB and machineC to machineA. I am running my below shell script from machineA. I have setup the ssh keys properly. If the files are not there in machineB, then it ...
1
vote
2answers
308 views

Gnu parallel & pipe

I want to send each line of a file to another program's stdin, e.g. input.txt line1 line2 line3 I want to use the gnu parallel like this (i.e. pipe each line as stdin to the more command) cat ...
1
vote
2answers
138 views

How do I iterate bash arrays and make an SCP command efficiently?

I need to scp the files from machineB and machineC to machineA. I am running my below shell script from machineA. I have setup the ssh keys properly. If the files are not there in machineB, then it ...
3
votes
3answers
1k views

Log commands executed over ssh

I would like to log all commands executed over SSH. Say, ssh something@server.com COMMAND I want to log "COMMAND" on server.com I did search extensively but could not find anything. There is ...
1
vote
1answer
2k views

Insserv rejected the script header

I was trying to make an init script for my debian install for supervisor. insserv: Service \$remote_fs has to be enabled to start service supervisor insserv: Service ...
1
vote
1answer
56 views

cp/rsync command with destination as symlink to a directory

I am working on a cPanel backup solution at the moment. We are now informed about this exploit. Exploit : Full ROOT ACCESS to server 1.) create malicious file from, normal user account: mkdir root ...
2
votes
2answers
211 views

executing .bash_profile alias via SSH

I would like to remotely execute a .bash_profile alias, but I cannot find the proper command. I tried: ssh user@host "bash -ic myalias" but it doesn't work I get: bash: cannot set terminal process ...
0
votes
2answers
47 views

Change/Deactivate the shell for an amount of users on SUSE Enterprise Server

I have a SUSE Server to which ~300 users are connecting. About 100 of them have to be deactivated. I think it would be nice to change their shell to /bin/false either with chsh or with usermod. ...
1
vote
3answers
1k views

Running ssh-agent from a shell script

I'm trying to create a shell script that, among other things, starts up ssh-agent and adds a private key to the agent. Example: #!/bin/bash # ... ssh-agent $SHELL ssh-add /path/to/key # ... The ...
0
votes
2answers
100 views

What seems wrong with this bash script? [closed]

I found an initscript that for some reason insists on starting the specified application as the root user. I can't wrap my head around why it is doing this, any hints? The script runs on Redhat ...
1
vote
2answers
193 views

Strange characters from output in shell

Over the past few years there have been some Linux systems that will output strange characters when running various commands. Here's an example of my output from the sensors command on one of those ...
2
votes
2answers
633 views

Shell script command output in if condition comparison fails to compare to same value string

I'm incorporating a script snippet which determines Android version via: adb shell getprop ro.build.version.release which returns: 4.1.2 or 4.0.4 The snippet currently looks like this: if [ "$(adb ...
0
votes
1answer
34 views

Running jobs in a HPC cluster [closed]

I'm quite new to HPC environment. Is there any difference in running a job on a node utilizing 8 cores and running the same job on 8 nodes utilizing I core in terms of performance or walltime used. ...
25
votes
3answers
2k views

Did a cat /dev/urandom - Broken terminal

Out of curiosity, when your shell character set breaks from doing something like cat /dev/urandom is there a way to fix that in place?
-1
votes
1answer
128 views

`pwd -P` preventing bash script from running in supervisord [closed]

I'm running supervisord to execute gunicorn. My problem is when my script contains CURR_DIR=`pwd -P` and run the script via supervisord, it STOPS the process. My script is located in /var/www/conf and ...
1
vote
2answers
93 views

If I know the PID number of a process can I know its name?

If I have the PID number for a process (on a UNIX machine), how can I know the name of its associated process? What do I have to do?
15
votes
2answers
696 views

Bash Prompt Below Output - Background Log Tail

I used to work for a company who had a customised shell for management of one of their products that was running on Linux and I'm looking to replicate a key feature of this shell. All the work was ...
1
vote
1answer
146 views

Shell script error on filename with spaces

I have a bash script that search for every static file located under my server root and stores a gzipped version next to each file. I got it from ...