LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-31-2018, 07:12 AM   #1
nareshreddyn
LQ Newbie
 
Registered: Sep 2017
Posts: 10

Rep: Reputation: Disabled
Please help me regarding the bash script


#!/bin/bash

echo "#################################################################"
echo "Unzip the Patch Files and Move to the Patch Home" >> ${LOG_FILE}
echo "#################################################################"
ssh ${appUsr}@${adminHost} "cd ${BINARIES_HOME}; find . -type f -mmin -120 -name '*.zip' -exec sh -c 'unzip -qd "`dirname "{}"`" "{}"' ';'; var=$(ls | grep -E '^[0-9]+$'); mv $var $PATCH_HOME;"


This is a part of a script.I can login to the adminhost and able to unzip the file.But unable to store the output in var. Any suggestions.

Below is the error i am getting
mv: missing destination file operand after `/opt/oracle/weblogic/12.2/OPatch'
Try `mv --help' for more information.
++ sleep 10

Any suggestions.Thanks a million in advance.
 
Old 08-31-2018, 07:46 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Please see the link in my signature about how to use CODE tags to enclose your script in them and have it appear as code.

Do you see the complaint?
Quote:
mv: missing destination file operand after `/opt/oracle/weblogic/12.2/OPatch'
This is telling you where the error is located. You do not have a destination file for your mv command. It would appear that you either do not have a valid $PATCH_HOME variable or valid $var variable.

Since your comment was that it did not store it in var, then my assumption is that you mean /var, and thus that part of your script should not say $var, but instead /var

Last edited by rtmistler; 08-31-2018 at 07:47 AM.
 
1 members found this post helpful.
Old 08-31-2018, 07:51 AM   #3
nareshreddyn
LQ Newbie
 
Registered: Sep 2017
Posts: 10

Original Poster
Rep: Reputation: Disabled
Hi,

Thanks for the update.$PATCH_HOME is available which is /opt/oracle/weblogic/12.2/OPatch. Here the problem is var is not storing the grep value.I tried different way which is working fine. I need to write the script in one line.

Here is the updated script which worked fine.

Quote:
ssh ${appUsr}@${adminHost} "cd ${BINARIES_HOME}; find . -type f -mmin -10 -name '*.zip' -exec sh -c 'unzip -qd "`dirname "{}"`" "{}"' ';';" >> ${LOG_FILE}
var=$(ssh ${appUsr}@${adminHost} "cd ${BINARIES_HOME}; ls | grep -E '^[0-9]+$'") >> ${LOG_FILE}
echo "$var" >> ${LOG_FILE}

ssh ${appUsr}@${adminHost} "mv ${BINARIES_HOME}/$var $PATCH_HOME;" >> ${LOG_FILE}
Please suggest.
 
Old 08-31-2018, 08:02 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,923

Rep: Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319
suggest what? you wrote the script was working fine.
 
Old 08-31-2018, 08:04 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Far as I know, you do something like the following notation:
Code:
$ ssh <user@host> << EOF
    command;
    command;
    command;
EOF
Give that notation a try. I've used it to inject multiple commands to fdisk, but haven't tried it with other commands.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] BASH Script - What am I doing wrong in this test? - BASH Script BW-userx Programming 34 04-08-2017 01:36 PM
[SOLVED] Bash Script - Reading User Input while Processing output from Command within Bash cleeky Linux - General 5 05-27-2014 02:57 PM
[SOLVED] Converting Script from Linux (GNU) Bash 4 to Solaris Bash 2.05 - Any cheat sheet? oly_r Solaris / OpenSolaris 6 05-03-2013 08:25 AM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 08:56 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration