Tag Info

Hot answers tagged

6

Try "./a.sh" when trying to execute it. It needs to know where the file is at. The './' tells it to look in the current directory.


4

Try: #!/bin/bash id touch script-run-user.file sudo -u appuser 'ksh' <<EOF # add list of cmds to execute id touch appuser.file EOF Edit: Just as an update, check out Here Documents. EOF = "End Of File", the name is arbitrary.


4

If you don't background the tail command in your script, the shell will wait for it to exit, which will never happen. If you have other work to do, after which you want to kill the tail command, you can tail -f logfile & tailpid=$! ...do some other stuff... kill $tailpid ...carry on...


3

When you type a command, the shell looks up the command from a list of directories, as specified by the PATH variable. The current directory is not in PATH by default (for security reason), so the shell can not find your script. Using ./, meaning the current directory, so the shell knows where is your script.


3

This is not a syntax error for actual ksh syntax, it's syntax error for invalid command name which only catched at run time. When you run it, you will get command not found error. If you add: echo foo ehco foo2 if [ 1 -lt 0 ] ...


3

If you're using a sh-compatible shell (like bash), that > prompt is called the "secondary prompt". It's set by the value of the PS2 variable, just like PS1 sets the normal prompt. You should be able to change it to # pretty easily: PS2='# ' You might want to put that into your ~/.bashrc (or whatever the equivalent is for whatever shell you're using).


2

It's not based on "the system". It's based on your shell. In bash or other Bourne shells PS2 The value of this parameter is expanded as with PS1 and used as the secondary prompt string. The default is ``> ''.


1

Start the command as a background task, with & at the end: nohup path_to_domain_bin/startWebLogic.sh>/dev/null < /dev/null 2>&1 & The output redirections are not helping much, as nohup redirects the output anyway, as you have noticed. To get rid of that, skip nohup and do what it does (rather, the essential part of it) in the script ...


1

The point of tail -f is to run forever until explicitly killed, so you'll have to arrange to kill it. If there is some logic that determines when the tail process is to be killed, obtain the process ID of tail and arrange to trigger its killing when desired. For example, if you want to kill it after a minute: tail -f file.log & tail_pid=$! sleep 60 ...


1

Let the read command to the splitting. read cmd arguments case $cmd in compile) … ;; esac


1

Let your shell expand the variable by using " instead of '. Example: victor@pyfg:~$ line_number=2 victor@pyfg:~$ sed -n "${line_number},${line_number}p" /etc/hosts 1.2.3.4 row-2 Since you're only printing a single row, you can just to it like this also: victor@pyfg:~$ sed -n "${line_number}p" /etc/hosts 1.2.3.4 row-2


1

I am guessing this. I didn't try it myself. Let's see if it works. expect_ACTIVATE=`cat << EOF` set timeout -1 spawn $VPNC expect : {send Pass123\r} expect "\\$ " send "status=`echo $?\r`" expect eof EOF



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