LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-16-2015, 03:00 AM   #1
ablopera
LQ Newbie
 
Registered: Jul 2015
Distribution: Centos 6.2
Posts: 14

Rep: Reputation: Disabled
Bash Script wont execute if called from a remote Windows PC


Hi Everyone!

Im trying to run a certain bash script in a linux server from a Windows PC using plink, but the script in Linux doesnt seems to run. The First script that will be called is the plucount_all.sh and then will call and pass the parameter to plucount.sh, after that from plucount_all.sh, it will call another script which is plucomp.sh

Bash Script
/Code
DATA_BACKUP_DIR=$LINUX/tmp/ToolsData/PLUCount
LOGFILE=$DATA_BACKUP_DIR/Data.log

mv $DATA_BACKUP_DIR/*.log
mv $DATA_BACKUP_DIR/Backup

if [ ! -d "$DATA_BACKUP_DIR" ];
then
mkdir $DATA_BACKUP_DIR
fi

rm $LOGFILE
rm $DATA_BACKUP_DIR/Data.log

START=01
END=63

for (( c=$START; c<=$END; c++ ))
do
plucount.sh $c >> $LOGFILE
done

rm /home/linux/tmp/Tools/log/pluserverhasrun

(cd /home/linux/tmp/Tools/ && ./plucomp.sh)

exit 0

======================================

Windows Command using plink
/Code
plink 1.1.1.1 -l user -pw pass bash -m COM.txt

=======================================

COM.txt contains
/Code
cd /home/linux/tmp/Tools
./plucount_all.sh


Errors after running in Windows prompt.
mv: target '/tmpToolsData/PLUCount': No such file or directory

rm: cannot revove '/tmpToolsData/PLUCount': No such file or directory

./plucount_all.sh: line XX: /tmp/ToolsData/PLUCount/Data.log : No such file or directory

sed: cant read /tmp/ToolsData/PLUCount/Data.log

grep: /tmp/ToolsData/PLUCount/Data.log: No such file or directory
 
Old 07-16-2015, 03:34 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
The first error message is clear - the directory /tmpToolsData/PLUCount doesn't exist. This might be caused by the script using a variable LINUX which is not set. Is that intentional?

Also, the mv commands in the script look pretty malformed. Perhaps you should first understand how the mv command is used.

Generally it's not quite clear to me what this script is supposed to achieve.
 
Old 07-16-2015, 04:07 AM   #3
ablopera
LQ Newbie
 
Registered: Jul 2015
Distribution: Centos 6.2
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
The first error message is clear - the directory /tmpToolsData/PLUCount doesn't exist. This might be caused by the script using a variable LINUX which is not set. Is that intentional?

Also, the mv commands in the script look pretty malformed. Perhaps you should first understand how the mv command is used.

Generally it's not quite clear to me what this script is supposed to achieve.
Hi, the script is supposed to query a remote linux pc and then compare it with static value indicated in the plucount.sh (another script called by plucount_all.sh).

No problem running the script on the actual Linux server, but when calling it from a windows pc via remote connection using plink, the error appears.
 
Old 07-16-2015, 06:01 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Perhaps when you run it on the server, the LINUX variable is set and the first error won't appear. It might help to know where the PLUCount directory is located.

But the line mv $DATA_BACKUP_DIR/Backup is unlikely to succeed in any circumstances. What is moved where?

Last edited by berndbausch; 07-16-2015 at 06:02 AM.
 
Old 07-16-2015, 06:56 AM   #5
ablopera
LQ Newbie
 
Registered: Jul 2015
Distribution: Centos 6.2
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
Perhaps when you run it on the server, the LINUX variable is set and the first error won't appear. It might help to know where the PLUCount directory is located.

But the line mv $DATA_BACKUP_DIR/Backup is unlikely to succeed in any circumstances. What is moved where?
Hi the PLUcount directory is located in /home/tmp/ToolsData/

Made some corrections

from:
/code
mv $DATA_BACKUP_DIR/*.log
mv $DATA_BACKUP_DIR/Backup

to:

/code
mv $POSDATA_BACKUP_DIR/*.log $POSDATA_BACKUP_DIR/Backup/

For the variables, it is being declared in the Linux box (part of the bash script), I assume I wont have problems with it.
 
Old 07-16-2015, 07:00 AM   #6
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by ablopera View Post

For the variables, it is being declared in the Linux box (part of the bash script), I assume I wont have problems with it.
You do though. LINUX is not set. I guess the bash script in question is not used when logging in from plink.
 
Old 07-19-2015, 10:26 PM   #7
ablopera
LQ Newbie
 
Registered: Jul 2015
Distribution: Centos 6.2
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
You do though. LINUX is not set. I guess the bash script in question is not used when logging in from plink.
Yeah your right, the other error that appears are the ones from the other script being called by the first script

/code
for (( c=$START; c<=$END; c++ ))
do
plucount.sh $c >> $LOGFILE
done


Should I declare all the Linux variables in the first script? Is there a way to have this corrected? Thanks you very much
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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] Why wont this script execute? kenny53067 Linux - Newbie 27 07-24-2011 07:05 PM
Bash script to read .txt files on a remote Windows 2003 R2 server via FTP laurens Linux - Newbie 25 05-15-2009 06:01 AM
can expect be called from within a bash script? johnpaulodonnell Programming 4 06-21-2007 09:42 AM
remote execute a bash script vmware Linux - Enterprise 3 09-07-2006 03:01 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:36 AM.

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