how to suppress the status of fork in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to suppress the status of fork in shell script
# 1  
Old 02-29-2012
Java how to suppress the status of fork in shell script

When command is executed by forking, the console displays the status of that command. I want to suppress it.. how to do it ?
Example:
Code:
 var1=`date` &
echo "hello world";

output:
hello world
[1]+ Done var1=`date`

I want to suppress the second line "[1]+ Done var1=`date`".
I tried >/dev/null but of no use...
# 2  
Old 02-29-2012
The status messages are suppressed on my RHEL GNU Bash when I do this:

Code:
$ (x=`date` &); echo "hello world"
hello world
$

Check if its the same behaviour on your system too.
# 3  
Old 02-29-2012
it didnt help

This aint working in Solaris and SUSE.
Though the message is suppressed the value of X is null.
# 4  
Old 02-29-2012
Or if you run the statements in a script:

Code:
$ cat test1
var1=`date` &
echo "hello world";
wait
$ ./test1
hello world

The point is that these messages are then handled by a sub shell..

---------- Post updated at 08:07 ---------- Previous update was at 08:00 ----------

Quote:
Originally Posted by Arun_Linux
This aint working in Solaris and SUSE.
Though the message is suppressed the value of X is null.
The variable will be null anyway because you run it in a subshell in the background by using & and then X gets set in that shell, not the parent shell and when it returns X will still be null because it was never set in the current shell..
# 5  
Old 02-29-2012
Java is there anyway to export values between shells

understood.. Btw is there any workarounds to achieve this ?
# 6  
Old 02-29-2012
What do you want to achieve?
# 7  
Old 02-29-2012
Java

Code:
$ cat test1
var1=`date` &
echo "hello world";
wait
echo "value of var1 is  $var1";
$ ./test1
hello world

I want to get the value of "var1"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Signal out from fork()'d shell script back to the C++ application

Hi, I am writing a C++ application; in which at one point I fork() a new process, which executes a shell script (via execv() call). Now the shell script can take a while to finish (tarring, burning a cd, etc.) and I would like to update the parent application about the progress (while the script... (3 Replies)
Discussion started by: mirni
3 Replies

2. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

3. Ubuntu

Help: how to call fork() in shell script? New to linux

Hi, I'm writing a shell script where I want to call fork(). However I wrote like this "var=fork()" in c style and got this error: "syntax error near unexpected token `(' " How could I call fork() in shell script? Thanks in advance. (2 Replies)
Discussion started by: Xiaoya
2 Replies

4. Shell Programming and Scripting

Help: how to call fork() in shell script? New to linux

Hi, I'm writing a shell script where I want to call fork(). However I wrote like this "var=fork()" in c style and got this error: "syntax error near unexpected token `(' " How could I call fork() in shell script? Thanks in advance. Duplicate Post - Continue Here - Please Do Not Cross Post... (0 Replies)
Discussion started by: Xiaoya
0 Replies

5. Shell Programming and Scripting

Help with Email Status shell script

I have written a bash script to to sort the data from logs i need some help in printing the outputs , i dont have much ideas in bah scripting. Sample script ----------------------- #!/bin/bash a=`date | cut -d " " -f2,2,3` cat /var/log/maillog |grep "$a" |grep -E -e 'deferred|bounced'... (9 Replies)
Discussion started by: unimaxlin
9 Replies

6. Shell Programming and Scripting

Run shell script from C program by calling fork and execl

I need to write a c program that uses the fork and excel system calls to run the shell script mode invoked like this: "./mode 644 ls -l" (that is the argumetns will always be 644 ls -l) here's the mode script: #!/bin/sh octal="$1" shift find . -maxdepth 1 -perm $octal -exec $@ {} \; ... (3 Replies)
Discussion started by: computethis
3 Replies

7. Shell Programming and Scripting

return status after run the shell script

Hello, I wanted to delete all files which are placed 14 days back. Here is my below script. My script works very well and it deletes all files 14 days back. I wanted to display message incase if the delete script is not successful. The below script returns always successful. But the directory... (6 Replies)
Discussion started by: govindts
6 Replies

8. Shell Programming and Scripting

status bar in shell script or perl

How To Generate different different progress bar in shell script? like we install some software it show us progress, like we install RPM that also show us progress. Thanks, Bash (2 Replies)
Discussion started by: learnbash
2 Replies

9. Shell Programming and Scripting

Suppress error message in shell script

Hi All this is a simple script #! /bin/bash FileCnt=`ls -lrt $DIR/* | wc -l` echo $FileCnt how could i escape the error msg if there are no files in $DIR ls: /home/sayantan/test/files/cnt/*: No such file or directory 0 Looking forward for a quick reply Regards, Newbie... (3 Replies)
Discussion started by: newbie07
3 Replies

10. Shell Programming and Scripting

checking exit status of a shell script

Hi, I have tried with the following code; if ;then echo "Failure." else echo "Success." fi to test the exit status of the test.ksh shell script. But whatever is the exit status of the test.ksh shell script Failure. is always printed. Please help. regards, Dipankar. (2 Replies)
Discussion started by: kdipankar
2 Replies
Login or Register to Ask a Question