How to get BASH to interpret pipes in a string correctly?
In a BASH library I'm creating, I have two functions that look like:
Which I use to launch, keep track of the PID, and prevent duplicates of any process in a system independent manner (there exists utilities like start-stop-daemon and startproc on different linux flavors, but they are not universal).
So if I want to use it to track a process over an SSH connection, I could do something like:
This would check the file my_process.pid and make sure that the process ID is not already running before going ahead to run the SSH connection and fork it in the background, while saving the new PID in the pid file.
The problem is, if I have a command like this:
then doing:
will not work, because BASH will interpret the '|' character literally and not as a pipe. Is there a way to force BASH to interpret '|' as a pipe even when it is in a string?
Hi,
I am new in bash scripting. In my work, I provide support to several users and when I connect to their computers I use the same admin and password, so I am trying to create a script that will only ask me for the IP address and then connect to the computer without having me to type the user... (5 Replies)
I booted into single user mode with
/usr/sbin/reboot -- -s
but after doing a control -d
my
who -r
shows
run-level 3 Nov 17 14:07 3 0 S
I was expecting it to show run-level S
why is this still in run level 3?
thanks (1 Reply)
I had been looking at page 75 of this online book:
http://richard.esplins.org/static/downloads/linux_book.pdf
I've used the system function in C to call bash commands before, but wanted to learn this way too. The solution in the book worked perfectly. However, I tried changing the simple "ls -l... (3 Replies)
Ksh is my default shell, but I want use the bash shell since its convenient to me.
When I type a long command line in a terminal, it does not wrap to the next line when I reach the end of the line and it wraps onto the same line, overwriting my prompt and the rest of what I typed.
$... (5 Replies)
Hi,
I have a function in a bash script that returns a string after some operations using awk.
The following code returns 555
$VARIABLE="EXAMPLE"
get_number $VARIABLE
this value I'd like to pass it as a second argument of another script with the following usage
myscript.sh <param1>... (7 Replies)
Was wondering if someone could interpret this for me -- I'm not sure what everything means. It's a shell script from my bash book:
cd ()
{
builtin cd "$@"
es=$?
echo "$OLDPWD ->$PWD"
return $es
}
what I don't quite understand is the "$@". I think, if I understand... (6 Replies)
HI All,
Im encountering behaviour that is not correct for my requirements when I untar a file.
Im using the below command to tar up files from various folders to the ARCHIVE folder as below...
tar -cvf "$ARCHIVE_PATH"/"$dte_tar_filename" "$LOG_PATH" "$PROCESSED_PATH2" "$ERROR_PATH"
... (5 Replies)
Hi guys,
I have no idea on unix but suddenly, my cobol programs calls a unix script that i know nothing about.
can you guys interpret these lines for me?
i know its a print command but I want to actually know how many copies it prints.
qprt -da -P $1 -t '6' -i '6' -l '70' $2
qprt -da... (1 Reply)