Tag Info

Hot answers tagged

13

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


10

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.


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

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


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 ...


4

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


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

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

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

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 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 ...


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 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

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 ;; ...


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 ...


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

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

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

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

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. We'll #!/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 ...


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

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

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

Your file has windows-style line endings. Use dos2unix or similar utilities to convert it to Linux line endings, and be careful next time you upload it.


1

You can use here documents to feed SSH scripts: ssh -T myhost <<EOF hostname whoami uptime EOF The '-T' option disables TTY allocation. I use this technique to run a standard script across multiple user accounts on one of our 3rd-party services which doesn't allow for a commonly-accessible writable bin directory. The SSH here-document method ...


1

Yo dawg, I heard you like shell, so I put shell in your shell so can shell while you shell. In other words, you are spawning a shell for your echo command and then just echoing everything in one line. Shell interprets that as just an echo command. Even if it did not, the fact that everything is in one line (especially that there is no new line after ...


1

rsync -e ssh -aHS $SOURCEDIR/ $TARGET:$TARGETDIR/ Use useradd with the original data (uid, gid, encrypted pw, ...) to recreate the user on the target system.



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