SEnding a process to backgorund (&) in here document


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SEnding a process to backgorund (&) in here document
# 1  
Old 04-03-2013
SEnding a process to backgorund (&) in here document

Trying to do the following

Code:
ssh root@192.168.0.111 'bash -s' <<ENDSSH
mkfifo a.pipe
gzip -c < a.pipe > aa.gzip &

ENDSSH

it does not seems to be able to send the gzip process to background.
# 2  
Old 04-03-2013
Quote:
Originally Posted by acelau
Trying to do the following

Code:
ssh root@192.168.0.111 'bash -s' <<ENDSSH
mkfifo a.pipe
gzip -c < a.pipe > aa.gzip &

ENDSSH

it does not seems to be able to send the gzip process to background.
I suspect that your problem is that there is no command with the name bash -s rather than that gzip isn't run in the background.

Try:
Code:
bash <<ENDSSH
mkfifo a.pipe
gzip -c < a.pipe > aa.gzip &
ENDSSH

instead and see if you get what you wanted.

If there is some reason why you think you need to invoke bash with the -s option to run this here document (even though that doesn't make any sense to me for this set of commands), at least drop the single quotes.

And if your current shell is bash (or any other shell that uses Bourne shell syntax), the following will do the same thing without the complexity of starting a new shell and having it read commands from a here-document:
Code:
mkfifo a.pipe
gzip -c < a.pipe > aa.gzip &

# 3  
Old 04-03-2013
Thanks for your reply.

Actually this is what i am doing.

Code:
#!/bin/ksh
FILE="a.pipe"
DS="DS1"
TIMESTAMP="TS"

ssh root@192.168.0.112 'ksh' <<ENDSSH
  # commands to run on remote host

for i in {1..8}
do
if [[ ! -e $DS\_$TIMESTAMP\_\$i.pipe ]]
then
mkfifo $DS\_$TIMESTAMP\_\$i.pipe
fi

gzip -c \< $DS\_$TIMESTAMP\_\$i.pipe \> $DS$TIMESTAMP\$i.gz &

done

ENDSSH

I am trying to trigger this script to a remote server to setup 8 pipe for 'on the fly' compression. I'm always getting

Code:
[root@twslinux1 ~]# ./a.sh
gzip: <: No such file or directory                                                                                           àD\QDS1_TS_1.pipegzip: >: No such file or directory
gzip: DS1TS1.gz: No such file or directory
gzip: &: No such file or directory
gzip: <: No such file or directory                                                                                           åD\QDS1_TS_2.pipegzip: >: No such file or directory
gzip: DS1TS2.gz: No such file or directory
gzip: &: No such file or directory
gzip: <: No such file or directory                                                                                           êD\QDS1_TS_3.pipegzip: >: No such file or directory
gzip: DS1TS3.gz: No such file or directory
gzip: &: No such file or directory
gzip: <: No such file or directory                                                                                           9J\QDS1_TS_4.pipegzip: >: No such file or directory
gzip: DS1TS4.gz: No such file or directory
gzip: &: No such file or directory
gzip: <: No such file or directory                                                                                           9J\QDS1_TS_5.pipegzip: >: No such file or directory
gzip: DS1TS5.gz: No such file or directory
gzip: &: No such file or directory
gzip: <: No such file or directory                                                                                           9J\QDS1_TS_6.pipegzip: >: No such file or directory
gzip: DS1TS6.gz: No such file or directory
gzip: &: No such file or directory                                                                                           9J\QDS1_TS_7.pipegzip: <: No such file or directory
gzip: >: No such file or directory
gzip: DS1TS7.gz: No such file or directory
gzip: &: No such file or directory                                                                                           9J\QDS1_TS_8.pipegzip: <: No such file or directory
gzip: >: No such file or directory
gzip: DS1TS8.gz: No such file or directory
gzip: &: No such file or directory
[root@twslinux1 ~]# vi a.sh
[root@twslinux1 ~]# ./a.sh                                                                                                   àD\QDS1_TS_1.pipegzip: <: No such file or directory
gzip: >: No such file or directory
gzip: DS1TS1.gz: No such file or directory

# 4  
Old 04-03-2013
Replace ssh root@192.168.0.112 'ksh' with cat so you can see exactly what values the here-document ends up with, and paste its output here in code tags please.

You don't need to escape < > . You do need to escape $ unless you want them substituted with local variables "right now".

You should use ${braces} for variables instead of separating them with \ too.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Identify process sending ldap requests to old DNS server

Hi, I have a Solaris 10 system, which appears to be sending out LDAP queries to a server that is due to be decomissioned. Is there a way to identify which process is sending out these queries? The problem is that the local port constantly changes, and the connections do not stay open long... (3 Replies)
Discussion started by: badoshi
3 Replies

2. Shell Programming and Scripting

Readin document & creating path

Need a way to read a file in who every line is a path to a directory and make shortcut to that directory on a specific place. Example: line in the document /media/gogo/6651-FEAB/Desktop/ /media/gogo/6651-FEAB/Desktop/alex/ /media/gogo/6651-FEAB/linux/ ... (3 Replies)
Discussion started by: gogok_bg
3 Replies

3. UNIX for Advanced & Expert Users

Sending keystrokes to another process

The third-party ERP system used by our company has no idle-out facility and we sometimes have issues because users simply walk away from their computers and leave sessions logged in for hours or even go home without logging out. (We are in a factory environment so it is hard to raise the care... (7 Replies)
Discussion started by: Wayne Ivory
7 Replies

4. UNIX for Dummies Questions & Answers

Sending signal from child to parent process!

Hi All, I facing a problem in handling signals between parent process communication. I am trying to send a signal(SIGINT) from child to parent. I am using kill function to do so and I am trying to read the signal using sigaction(). But the program is ending abruptly and I am not able to figure out... (4 Replies)
Discussion started by: vkn_1985
4 Replies

5. Shell Programming and Scripting

sending email as background process

Hi All, Solaris Bash v3x I have a script that accepts an error code, and if the error code is not 0 then an email is sent using mailx to details the error. I want to be able to implement the functiuonlity whereby i can send the email in a background process so the script can continue with... (3 Replies)
Discussion started by: satnamx
3 Replies

6. Shell Programming and Scripting

Issue in mail sending process

Hi I created one CSV file and i need to append some message in the content of my mail. $sales=sales.dat $sales_csv=sales.csv $sales_report=sales.txt this is the command am using it. echo "sales for `date`"| read subject uuencode $sales $sales_csv | mailx -ms "${subject}."... (2 Replies)
Discussion started by: bobprabhu
2 Replies

7. Shell Programming and Scripting

creating & sending formatted (with bolds & colors) CSV

Hi , I have a situation. Need is to create & send a formatted file with header in BOLD & colored & some sequel results as a content. I know echo -e \033 command, but its scope is limited in PUTTY. How to retain the formatting out of Putty; say after someone opens a email attachment... (2 Replies)
Discussion started by: infaWorld
2 Replies

8. Shell Programming and Scripting

Sending email with text & attachment using mailx

I spent some time working this out, with a little help from various forums, and thought the community would like to know : Here is how you can send an email from a single Unix command line : /usr/bin/echo "Email text\nNew line\nAnother new line" >x | uuencode sourcefile.txt sourcefile.txt |... (3 Replies)
Discussion started by: haryadoon
3 Replies

9. UNIX for Dummies Questions & Answers

Sending Emails to a unix process

Hi , I need to have a unix process which is setup to read all incoming mail for some user and process the same. How tough it is to code the same.Is there any way that we can download some shell scripts for the same from some internet site Kindly help. (2 Replies)
Discussion started by: xsriniva
2 Replies
Login or Register to Ask a Question