0
votes
2answers
75 views

Getting errors trying to run shell script (Linux)

I'm trying to run the following script. I have run it before without issue, but now I encounter an error. #!/bin/bash # init function pause(){ read -p "$*" } echo & echo "(Website):" ...
1
vote
1answer
82 views

Bash error while running script

I have a CentOS 6.5 64-bit dedicated server. The only thing I done on it is yum install java7, so I have not installed any other stuff. So in the directory /root I made this file (test.sh) ...
0
votes
0answers
13 views

Make a script identify DBUS session address and use it

I'm using cron with notify-send to display some notifications, but it requires DBUS session to run Here is the script: export DBUS_SESSION_BUS_ADDRESS=[session] #!/bin/sh { DISPLAY=:0 ...
-1
votes
2answers
25 views

What is the risk when editing crontab file without the “crontab -e” command?

I developed a script in which I add lines to the crontab file with echo command and I remove lines with sed command. I do not know the risk of that especially that I find in some web site that we ...
-1
votes
2answers
77 views

How can I change the “/” path in linux [closed]

When I type cd /, it changes my directory to a default one. How can I override the current settings so that / points to a different directory.
0
votes
2answers
24 views

Copy shell configuration from one machine to another?

I've got login to another server where shell configurations are not like I would want. For example I don't see my username and CWD on prompt, and when I press arrow key, instead of giving last entered ...
2
votes
1answer
175 views

Redirect stdout/stderr of a background job from console to a log file?

I just run a job (assume foo.sh). ./foo.sh [Press Ctrl-Z to stop] bg # enter background And it generate output to stdout and stderr. Is there any method to redirect to stdout and stderr to other ...
1
vote
0answers
166 views

execl: couldn't exec `/bin/sh'

I accidentally moved the whole bin, boot, dev and etc directory. After moving everything back I get the following error email from various cron jobs: execl: couldn't exec `/bin/sh' execl: No such ...
0
votes
1answer
93 views

How can I encode an url for wget?

I am looking for a way to convert a string to a clean url. For example : wget http://myurl.com/toto/foo bar.jpg This is going to download http://myurl.com/toto/foo and http://bar.jpg. I want to ...
0
votes
1answer
56 views

Issues with this sh script?

Having issues executing this sh script...i don't see anything wrong with it, does someone else see something I screwed up? echo "**************************************" echo "*** ...
0
votes
1answer
28 views

Is there a way to pass a statement via an argument in shell?

What I'm trying to achieve is to set the title of a widget when computer goes to idle: xsidle.sh echo mywidget.title = "idle" | awesome-client when i remove xsidle.sh it works flawlessly. xsidle.sh ...
1
vote
1answer
153 views

Why do I sometimes get 'sh: $'\302\211 … ': command not found' in xterm/sh?

Sometimes when I simply type a valid command like 'find ...', or anything really, I get back the following, which is completely unexpected and confusing (... is command name I type): sh: ...
1
vote
1answer
51 views

bash says '[[:' not found. what does that mean?

While running a bash script, I get this error: sh: [[: not found How can I find what where is the problem?
1
vote
1answer
1k views

Why does subshell not inherit exported variable (PS1)?

I am using startx to start the graphical environment. I have a very simple .xinitrc which I will add things to as I set up the environment, but for now it is as follows: catwm & # Just a basic ...
0
votes
3answers
170 views

Write pipe result to variable

I need to be able to write whether the test for a grep is either TRUE or FALSE to a variable so I can use it later For the following, if I run defaults read com.apple.Finder | grep ...
0
votes
1answer
474 views

useradd denies home directory creation Ubuntu 13.04

I'm trying to set up a git user, but am getting the error useradd: cannot create directory /srv/data/git when running this command sudo useradd \ --create-home ...
0
votes
1answer
67 views

How to make an alias and work in sh for all users (not in bash)?

My question maybe is silly, but how can I make an alias so as to work in sh for all users? I know that I can put an alias, let say this one: alias ls='ls -l' in /etc/bash.bashrc so as to work in ...
1
vote
1answer
436 views

Linux: How to eval the contents of STDOUT?

Consider you have a file with some sort of terminal command. How might each line be executed? Can you pipe the output of more into an eval? %> more ./foo.txt Edit: After some help/guidance ...
2
votes
2answers
355 views

Allow any user/password entry in ssh

I want to setup ssh so that one can login with any username or password and be accepted. If they chose a username and password of an actual user on the system they will successfully login and use ssh ...
0
votes
1answer
233 views

Bash: Copy logs to other file and remove copied log

I am using linux and doing some bash scripting. I have a log file which is making logs of all the events/changes our in particular directory. I need to copy these logs to some other file so that I can ...
2
votes
4answers
1k views

How do I start in bash when ssh'ing into my server?

I have a hosted Debian server. When I log in via ssh, I'm greeted with a sh environment. How do I change it so I start in a bash environment?
2
votes
3answers
1k views

How can cat/print a file except the last 2 lines?

How can get a file, except the last (for instance) 2 lines, with standard or GNU shell tools? (bash, tail, cat and so on.)
0
votes
1answer
136 views

I changed the symbolic link /bin/sh by accident

I am working on Ubuntu 11.1. The symlink /bin/sh pointed to dash in my system. /bin/bash pointed to sh. I accidentally changed /bin/sh to point to /bin/bash. Now, I can't open the terminal. How can I ...
2
votes
2answers
192 views

Record bash_history to private database for all users?

I want to be able to setup a MySQL database and record all commands issued on my server by username and command. Is this possible, and if so, how would I set it up?
1
vote
3answers
374 views

How to find out environment variables set after logging into a shell session

How can I find out the environment variables set after logging into a shell session? My two dummy solutions have been so far as follows: _VariableName1="VarValue1";export _VariableName1; ...
4
votes
3answers
7k views

How do I change my default shell to bash if I don't have access to chsh nor /etc/passwd?

I'm working on a university remote Linux account, and the default shell is sadly csh without tab completion. How can I change my account's default shell to bash? chsh is not available.
0
votes
2answers
692 views

How to use sudo with rcp command to copy files from linux host to HP-UX host?

I'm having this issue where when I try to use sudo to rcp some files from a Linux host to an HP-UX host (note that the destination directory requires root access to write to), I get the following ...
0
votes
1answer
1k views

sh: time command not found

In llvm 3.0 test-suite, the snippet of code bellow gives the following error on bash: sh: time command not found if [ "x$RHOST" = x ] ; then ( sh -c "$ULIMITCMD $TIMEIT -p sh -c '$COMMAND ...
0
votes
0answers
223 views

bash script rm cannot delete folder created by php mkdir

I cannot delete folder created by php mkdir for I in `echo $*` do find $I -type f -name "sess_*" -exec rm -f {} \; find $I -type f -name "*.bak" -exec rm -f {} \; find $I -type f -name ...
0
votes
1answer
252 views

Loop until user presses 'C' in sh file

What I want is as follows: At first when user runs .sh file it displays following: Review id: You id is:XXX000YYY Do you want to change it?[Press Y to change, C to continue]: Now If user presses Y ...
1
vote
3answers
729 views

Renaming a file from myFile.sh to myFile.bash?

PART 1 Ok so i'm using Mac and I started out with a file called... Example: myFile.sh In Terminal I ran this file in its directory by typing... bash myFile.sh That works perfectly, but then I did ...
1
vote
1answer
931 views

sh alias: command not found

I have written a very simple script like this: function apply_to_dev { echo "Applying scripts to DEV..." alias ISQL="isql -Uuser -Ppwd -SDEV -DDATA -I ~/bin/interfaces" shopt -s nullglob ...
2
votes
1answer
359 views

sh on Lion can't cd into folders with implicit paths (causing make to fail constantly)

I've had a problem with my OSX 10.7 Lion install for some time and I finally took some time to investigate. The issue is that when running make, I always get an error of the form: /bin/sh: line 0: ...
5
votes
3answers
137 views

CD into directory with “-” in the beginning

I have a problem with cd-ing into folder named "--Recovery Files" and can't remember how to escape dashes in the filename. Any ideas?
2
votes
2answers
507 views

Log Files from bash script output

I have a script that runs (this works fine). I'd like to produce logfiles from its output and still show it on screen. I have this command that creates three files from this blog: ((./fk.sh ...
2
votes
2answers
604 views

How run sudo -s after ssh login

My Step By Step: On myserver.com i paste line "sudo -s" to file "~/.bashrc" in home directory for "mylogin" SSH Login to mylogin@myserver.com After login: root@myserver.com:~$ But, press cntrl+D ...
0
votes
1answer
1k views

How to check for program exit code in Linux?

I want to check in a shell script whether subversion is installed. For that I chose to check the exit code after the program has been executed. I tried using command svn, but that prints out the ...
7
votes
2answers
2k views

Comments in a multi-line bash command

This single-command BASH script file is difficult to understand, so I want to write a comment for each of the actions: grep -R "%" values* \ | sed -e "s/%/\n%/" \ | grep "%" \ | grep -v " % " \ | ...
9
votes
3answers
2k views

How is install -c different from cp

What is the difference between install -c and cp? Most installations tend to use install -c, but from the man page it doesn't sound like it does anything different than cp (except maybe set ...
8
votes
2answers
705 views

Making bash TAB completion more like cmd.exe [duplicate]

I wondered if theres a way to do rotational style completion in bash similar to the behavoir on cmd.exe, I've found it speeds me up in regard to entering commands
1
vote
3answers
239 views

Read everything that has been echo'd and 'errored' to terminal window?

I've inherited a complex shell script running on OSX that gets run on a crontab. Within the script I would like to periodically read everything in the terminal window and write it to another file... ...
1
vote
2answers
3k views

What happens to the environment when you run “su -c”?

What happens to the environment when you run "su -c"? The reason I ask, is this mysterious behavior: bash$ which firefox /usr/local/bin/firefox bash$ su - user -c "echo $PATH" ...
3
votes
1answer
400 views

Forcibly break a for loop in sh

If I run a for loop on the command line in sh, and I press control-C, it usually cancels the current running process, so I need to hold ^C until the shell itself catches it and breaks the loop. Is ...
4
votes
2answers
217 views

shell dotfiles and *rcs: what's a sane setup?

A bash user will eventually end up with .bashrc, .bash_profile, .profile, and maybe some more. Now, each file gets loaded unders particular situations, and it all leads to confusion and frustration. ...