Hot answers tagged

20

You've mistakenly put: export EDITOR=/usr/bin/emacs into your /etc/inputrc. This will map the letter 'e' to nothing at all. Remove that and you should be fine.


17

For existing users: chsh -s SHELL USER chsh -s /usr/local/bin/bash root For future users: Edit "/etc/pw.conf" defaultshell keywords When use adduser(), choose necessary shell


9

Most interpreters have a parameter to specify some code to execute. You can use this to invoke a specific interpreter and provide the code. For example: bash -c 'function run_free() { free -m; }; run_free' (Note that you need some semicolons in there since you don't have newlines.) perl uses -e, and python uses -c.


8

You need to replace /bin/sh with something; that's the key. If you can get into the FreeBSD loader during startup (with an "ok" prompt) try something like this: set init_shell=/bin/csh unset init_script unset init_path I got this information from loader(8) from the FreeBSD manual pages (online). I've not done this, but it should work (assuming that ...


6

OK, First the lecture: DON'T MESS WITH SYSTEM BINARIES Anything in /bin, /sbin and /rescue on FreeBSD should be left alone. Even if you know what you're doing (if you know what you're doing you also know these should be left alone. They're really important -- all of them!) DON'T delete /bin/sh. EVER. On any *NIX system that has it. Really. Don't do it. ...


5

The enviroment for cron to run into is very very limited, try to always use full path for binaries. #!/bin/sh /usr/bin/php /home/v/file.php /bin/sh /root/x/some.sh This considers that your php binary is in /usr/bin/php, please change that appropiately if it's not the case Also try to add in top of your cron the MAILTO line in order to get a direct mail ...


5

use dos2unix - it will convert your file to unix newline syntax


4

Yes, use dos2unix. Note that ^M is a carriage return, also denoted as \r. Another way to remove them is sed -i 's/\r$//' file ...


4

Tie STDOUT to another handle if you are in verbose mode, otherwise link those handles to /dev/null. Then write your script so the optional stuff points to the extra handles. #!/bin/sh exec 6>/dev/null if [ $# -ge 1 -a "$1" = "--verbose" ]; then echo "Verbose mode." exec 6>&1 fi echo "Things I want to see regardless of my verbose switch." ...


4

sh is just a standard executable, which is always a specific shell. There is no magic to detect which shell to use. % whereis sh sh: /bin/sh % ls -l /bin/sh lrwxrwxrwx 1 root root 4 Mar 29 11:53 /bin/sh -> dash On Ubuntu systems, /bin/sh is (by default) a symlink to dash, which is a minimal POSIX shell intended for non-interative use. If you run sh ...


4

Instead of symlinking, copy your bash into /bin/sh. Use the ldd command to find any libraries that might reside on filesystems other than rootfs and copy them over to rootfs as well.


4

At the user's shell prompt: source ~/.profile Or . ~/.profile


4

You can try to return the name of the parent process with something like this: - ps -ocommand= -p $PPID | awk -F/ '{print $NF}' | awk '{print $1}' For me this returned konsole when I ran this interactively. or you could script in some logic to handle situations. while getopts cm opt do case $opt in c) ## Do crontask ;; ...


4

Run the rpm command with sudo: #!/bin/sh mkdir -p /data/workday/cred chown -R myuser:myuser /data sudo -u myuser rpm -Uvp --force --nodeps --prefix /data/place /data/RPMs/myrpm.rpm


3

The process ID is off by one because you have put an extra & after the $javaCommandLine. In other words, you have put two processes in the background before calling echo $!, thus getting the PID of >>$serviceLogFile 2>&1 rather than $javaCommandLine. Those two pieces should be put in one, as the old 2 line codes shows su ...


3

I wrote this Perl program a long time ago that could get you started if you understand it. It uses uses the inotify feature in the kernel. http://www.win2ix.ca/2013/05/31/606/ You'll have to change the code from synchronization to doing whatever you need, but it's mostly all there. I know you have a problem with Perl, but I wanted to give this to you just ...


3

Your guess is right. exec >filename command redirects stdout to the designated file. This sends all command output that would normally go to stdout to that file. command &> filename redirects both the stdout and the stderr of command to filename. Actually, command &>file is another form of command > file 2>&1 (not available in ...


3

The problem you've stated is possibly related to difference in PATH of you when you execute script as logged-in user and when script is executed at startup. The output of 'which' depends on PATH. So if place where your executable resides is not on PATH, it will return nothing. I'd advice you to specify path to executable in $command explicitly. Or modify ...


3

This is another idea that I had, which is that the loop might be losing the position args; directory1=$1 directory2=$2 echo "starting" > /var/www/html/${directory2}.log rep=`du -sk /home/repository_${directory1} | awk '{print $1}'` dirsize=`du -sk /home/${directory2} | awk '{print $1}'` while [ "$dirsize" -lt "$rep" ]; do dirsize=`du -sk ...


3

The simplest way to run a command once at startup is to put it in /etc/rc.d/rc.local, which is a link from /etc/rcX.d/S99local, and gets run at the very end of the boot sequence. It's better to write, debug and link a proper service startup script, but if you're pushed for time and just want to whack in a one-line launch command, I find that's the best ...


2

The problem is with they way windows services work. This fixes the problem: Close Cygwin Go to windows services (services.msc on Run Dialog). Stop the CYGWIN sshd service Double click on CYGWIN sshd to enter the service properties Stop the service Under the Log On tab, ensure that Log on as is set to Local System account and Allow service to interact with ...


2

The shell script should be: SOURCEWITHSPACES=( "${PREFIX}/Documents and Settings/." "${PREFIX}/electronic claims/." "${PREFIX}/billing statements/." ) for P in "${SOURCEWITHSPACES[@]}"; do echo "$P"; done


2

The shell builtin you're looking for is disown, which re-parents backgrounded jobs to init so that the script can exit leaving them safely in the background. You probably want to redirect output to /dev/null (or a log file) in order to avoid getting output in the shell after starting the script. ssh hostname 'command' &>/dev/null & disown


2

It is probable the php binary isn't in the default cron PATH. You should put the full path to your php binary in your script /usr/bin/php /home/v/file.php You should also provide a path for sh /bin/sh /root/x/some.sh


2

If you don't have bash installed already, then the FreeBSD preferred way is to use the ports: cd /usr/ports/shells/bash make install clean If you don't have the ports tree installed, you can install it by running: portsnap fetch extract Doing either of these things will need root privs. Note also, that typically bash is installed in ...


2

I don't have access to a freebsd box, but try this: #!/bin/bash fullpath="$1" filename=$(basename $fullpath) dir=$(dirname $fullpath) ext=$(echo $filename | awk -F. '{ print $NF }') base=$(echo $filename | sed "s/.${ext}//") if [ -f $fullpath ]; then if [ $ext != "mp4" ]; then ffmpeg -threads 4 -i $fullpath -y -vcodec libx264 -g 100 -bt 100k mp4 -vpre ...


2

Either clone the git repo as @alexises suggests which is the most general solution or if you're actually using github.com you can get to the files directly on https://raw.github.com which is explained more fully here.


2

I don't know about sh but in bash (not the same!) you'll need to use eval: $ x='> foo' $ echo Hi $x Hi > foo $ eval echo Hi $x $ cat foo Hi


2

there is no universal way at all. using interactive/noninteractive shell detection or tty detection is not reliable either, as other cases than cron can have these characteristics. just add a variable in your cron entry. say you need to run test.sh, then use this instead. $ RUNENV=cron ./test.sh cron cat ./test.sh #!/bin/sh echo $RUNENV This is fairly ...


1

When you type ./scriptname.sh the ./ says "only look in this folder for scriptname.sh". And you are doing that, in a folder where scriptname.sh does not exist, so the shell returns "No such file or directory". The fact that your restart.sh script is calling ./shutdown.sh on your behalf makes no difference, you're still in a folder where shutdown.sh doesn't ...



Only top voted, non community-wiki answers of a minimum length are eligible