You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Baz <ba...@goodconsultants.com> on 2005/04/12 17:37:33 UTC

Help with some shell script and ssh command problems...

Hi all,

I know this might be a little off the topic but i know this group can help 
me with my questions.

I am trying to execute a ssh command from a shell script. When execute, this 
script build.sh fine if i do: ./build.sh

However, if i do: ./build.sh > logfile 2>&1 ,the ssh command will hang from 
time to time and i cannot figure out the reason. The same problem with using 
"exec > $LOG_FILE 2>&1" within the script to capture logs.

Please help before i hurt my head scratching :)

I attached a couple of functions that I used SSH command within the script 
and hope someone can help to identify the issue...

Thank you.

Barry

# ---------------- FUNCTIONS -----------------
#

stop_weblogic () {

echo
echo "INFO: START: stop_weblogic"
echo
echo
echo "INFO: Stopping the weblogic server in host $HOST..."
(ssh -q $HOST "cd $MODULE_BIN_DIR; ant stop_weblogic") &

echo
echo "INFO: COMPLETED: stop_weblogic"

sleep 10

}

build () {

echo
echo "INFO: START: build"

echo
echo "INFO: Creating build number."
echo
echo
(ssh -q $HOST "cd $MODULE_BIN_DIR; ant build_number")

echo
echo "INFO: DO ALL!."
echo
echo
(ssh -q $HOST "cd $MODULE_BIN_DIR; ant do_all")

echo
echo "INFO: Doing EJB."
echo
echo
(ssh -q $HOST "cd $MODULE_BIN_DIR; ant ejb_jars_uptodate")

echo
echo "INFO: COMPLETED: build"

}

# ----------------- MAIN ---------------------
#

exec > $LOG_FILE 2>&1

echo
echo "INFO: START: `date`"

notify_start;
stop_weblogic;
#get_latest;
pre_build;
#build;
post_build;
start_weblogic;
check_if_wl_server_started;
checkbuild.sh $LOG_FILE
notify_complete;

echo
echo "INFO: END: `date`"

--------------------------------------------
My mailbox is spam-free with ChoiceMail, the leader in personal and corporate anti-spam solutions. Download your free copy of ChoiceMail from www.choicemailfree.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Help with some shell script and ssh command problems...

Posted by Ricky Clarkson <ri...@gmail.com>.
>From the SSH man page:

"Using the default values for
     PreferredAuthentications, the client will try to authenticate first using
     the hostbased method; if this method fails, public key authentication is
     attempted, and finally if this method fails, keyboard‐interactive and
     password authentication are tried."

Maybe ssh is trying to get a password from the user.  If you want to
disable this, you probably need to set whatever
PreferredAuthentications is, wherever it is set.

Can this all be done in a more portable way using JSch? (
http://www.jcraft.com/jsch/ )

On 13/04/05, Rhino <rh...@sympatico.ca> wrote:
> Your question has nothing whatever to do with Ant.
> 
> You may get lucky and get an answer anyway but you'd have a lot better
> chance to post to a newsgroup that specializes in shell script questions. I
> believe there are some BASH newsgroups for example.
> 
> Rhino
> 
> ----- Original Message -----
> From: "Baz" <ba...@goodconsultants.com>
> To: "Ant Users List" <us...@ant.apache.org>; <ba...@goodconsultants.com>
> Sent: Tuesday, April 12, 2005 11:37 AM
> Subject: Help with some shell script and ssh command problems...
> 
> > Hi all,
> >
> > I know this might be a little off the topic but i know this group can help
> > me with my questions.
> >
> > I am trying to execute a ssh command from a shell script. When execute,
> this
> > script build.sh fine if i do: ./build.sh
> >
> > However, if i do: ./build.sh > logfile 2>&1 ,the ssh command will hang
> from
> > time to time and i cannot figure out the reason. The same problem with
> using
> > "exec > $LOG_FILE 2>&1" within the script to capture logs.
> >
> > Please help before i hurt my head scratching :)
> >
> > I attached a couple of functions that I used SSH command within the script
> > and hope someone can help to identify the issue...
> >
> > Thank you.
> >
> > Barry
> >
> > # ---------------- FUNCTIONS -----------------
> > #
> >
> > stop_weblogic () {
> >
> > echo
> > echo "INFO: START: stop_weblogic"
> > echo
> > echo
> > echo "INFO: Stopping the weblogic server in host $HOST..."
> > (ssh -q $HOST "cd $MODULE_BIN_DIR; ant stop_weblogic") &
> >
> > echo
> > echo "INFO: COMPLETED: stop_weblogic"
> >
> > sleep 10
> >
> > }
> >
> > build () {
> >
> > echo
> > echo "INFO: START: build"
> >
> > echo
> > echo "INFO: Creating build number."
> > echo
> > echo
> > (ssh -q $HOST "cd $MODULE_BIN_DIR; ant build_number")
> >
> > echo
> > echo "INFO: DO ALL!."
> > echo
> > echo
> > (ssh -q $HOST "cd $MODULE_BIN_DIR; ant do_all")
> >
> > echo
> > echo "INFO: Doing EJB."
> > echo
> > echo
> > (ssh -q $HOST "cd $MODULE_BIN_DIR; ant ejb_jars_uptodate")
> >
> > echo
> > echo "INFO: COMPLETED: build"
> >
> > }
> >
> > # ----------------- MAIN ---------------------
> > #
> >
> > exec > $LOG_FILE 2>&1
> >
> > echo
> > echo "INFO: START: `date`"
> >
> > notify_start;
> > stop_weblogic;
> > #get_latest;
> > pre_build;
> > #build;
> > post_build;
> > start_weblogic;
> > check_if_wl_server_started;
> > checkbuild.sh $LOG_FILE
> > notify_complete;
> >
> > echo
> > echo "INFO: END: `date`"
> >
> > --------------------------------------------
> > My mailbox is spam-free with ChoiceMail, the leader in personal and
> corporate anti-spam solutions. Download your free copy of ChoiceMail from
> www.choicemailfree.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> > --
> > No virus found in this incoming message.
> > Checked by AVG Anti-Virus.
> > Version: 7.0.308 / Virus Database: 266.9.7 - Release Date: 12/04/2005
> >
> >
> 
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.9.7 - Release Date: 12/04/2005
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Help with some shell script and ssh command problems...

Posted by Rhino <rh...@sympatico.ca>.
Your question has nothing whatever to do with Ant.

You may get lucky and get an answer anyway but you'd have a lot better
chance to post to a newsgroup that specializes in shell script questions. I
believe there are some BASH newsgroups for example.

Rhino

----- Original Message ----- 
From: "Baz" <ba...@goodconsultants.com>
To: "Ant Users List" <us...@ant.apache.org>; <ba...@goodconsultants.com>
Sent: Tuesday, April 12, 2005 11:37 AM
Subject: Help with some shell script and ssh command problems...


> Hi all,
>
> I know this might be a little off the topic but i know this group can help
> me with my questions.
>
> I am trying to execute a ssh command from a shell script. When execute,
this
> script build.sh fine if i do: ./build.sh
>
> However, if i do: ./build.sh > logfile 2>&1 ,the ssh command will hang
from
> time to time and i cannot figure out the reason. The same problem with
using
> "exec > $LOG_FILE 2>&1" within the script to capture logs.
>
> Please help before i hurt my head scratching :)
>
> I attached a couple of functions that I used SSH command within the script
> and hope someone can help to identify the issue...
>
> Thank you.
>
> Barry
>
> # ---------------- FUNCTIONS -----------------
> #
>
> stop_weblogic () {
>
> echo
> echo "INFO: START: stop_weblogic"
> echo
> echo
> echo "INFO: Stopping the weblogic server in host $HOST..."
> (ssh -q $HOST "cd $MODULE_BIN_DIR; ant stop_weblogic") &
>
> echo
> echo "INFO: COMPLETED: stop_weblogic"
>
> sleep 10
>
> }
>
> build () {
>
> echo
> echo "INFO: START: build"
>
> echo
> echo "INFO: Creating build number."
> echo
> echo
> (ssh -q $HOST "cd $MODULE_BIN_DIR; ant build_number")
>
> echo
> echo "INFO: DO ALL!."
> echo
> echo
> (ssh -q $HOST "cd $MODULE_BIN_DIR; ant do_all")
>
> echo
> echo "INFO: Doing EJB."
> echo
> echo
> (ssh -q $HOST "cd $MODULE_BIN_DIR; ant ejb_jars_uptodate")
>
> echo
> echo "INFO: COMPLETED: build"
>
> }
>
> # ----------------- MAIN ---------------------
> #
>
> exec > $LOG_FILE 2>&1
>
> echo
> echo "INFO: START: `date`"
>
> notify_start;
> stop_weblogic;
> #get_latest;
> pre_build;
> #build;
> post_build;
> start_weblogic;
> check_if_wl_server_started;
> checkbuild.sh $LOG_FILE
> notify_complete;
>
> echo
> echo "INFO: END: `date`"
>
> --------------------------------------------
> My mailbox is spam-free with ChoiceMail, the leader in personal and
corporate anti-spam solutions. Download your free copy of ChoiceMail from
www.choicemailfree.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.9.7 - Release Date: 12/04/2005
>
>



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.7 - Release Date: 12/04/2005


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org