Expect script executes .pl before mount finishes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect script executes .pl before mount finishes
# 1  
Old 11-13-2013
Expect script executes .pl before mount finishes

Hi,

I'm trying to mount machines that are 'ON' with an expect script. I would put these guys in fstab, but the virtual machine that runs script seems to freeze up/shutdown if one of the machines I'm trying to connect to is 'OFF'. Following the mount, I run a perl script that accesses the 'ON' machines and moves their data to the virtual machine.

My problem. Is when I execute the expect script
[1] the mount occurs (GOOD) (.sh)
[2] the perl script executes (GOOD) (.pl)
[3] no data transfers (BAD) (.pl)

Something that stumps me is that when I run the perl script by itself (and a machine is mounted). The data transfers. It is just when I run it in the expect script that it doesn't. So, it makes me believe it's something in my expect script. Everything executes in the expect script, so maybe the perl script is running before the mount complete? I put eof in there for that reason.....idk, that's why I'm here.



All in all I have three scripts.

The expect script.
Code:
#!/usr/local/bin/expect -f

spawn bash /dilts/AGIauto/mountcheck.sh
expect "*?assword for informatics:*" {send "password"}
expect eof

spawn perl /dilts/AGIauto/pullAGIdata.pl
expect eof

The shell script (does the mounting)
Code:
#!/bin/bash

#............................mount check
#.....AGI clinical
sudo mount -t cifs -o username=Ren_user,password=AIB#1109$,nounix,sec=ntlmssp  //10.204.129.234/Desktop /mnt/clin
ical/234mac

And the perl script (grabs/moves the data)
Code:
#!/usr/bin/perl

use strict;
use warnings;


#.....clinical (cln)
my $cln_MACdir233 = "/mnt/clinical/233mac";
my $cln_MACdir234 = "/mnt/clinical/234mac";
my $cln_WINdir243 = "/mnt/clinical/243win";

#.....molecular (mol)
my $mol_WINdir245 = "/mnt/molecular/245win";
my $mol_WINdir246 = "/mnt/molecular/246win";
my $mol_WINdir247 = "/mnt/molecular/247win";
my $mol_WINdir248 = "/mnt/molecular/248win";


my @WIN_AGIpaths = ($cln_WINdir243,
                $mol_WINdir245,
                $mol_WINdir246,
                $mol_WINdir247,
                $mol_WINdir248,
                );

my@MAC_AGIpaths = ($cln_MACdir233,$cln_MACdir234);


foreach my $path (@WIN_AGIpaths){

        opendir(DIR, $path) or die $!;

        while (my $f = readdir(DIR)) {

                next unless (-f "$path/$f");
                next unless ($f =~ m/^results/);
                my $result = "$path/$f";
                system("cp $result /dilts/AGIauto/pulleddata"); #change to 'mv'

        }

        closedir(DIR);
}

foreach my $path (@MAC_AGIpaths){

        opendir(DIR, $path) or die $!;
        while (my $d = readdir(DIR)) {

                next unless (-d "$path/$d");
                next unless ($d =~ m/^Reports_/);
                my $resultDIR = "$path/$d";


                        if (-e "$resultDIR/ResultsDet.txt"){

                                my $id;
                                if ($resultDIR =~/Reports_(.*)/){$id = $1;}
                                my $passname =  "/dilts/AGIauto/pulleddata/".$id."_ResultsDet.txt";
                                system("cp $resultDIR/ResultsDet.txt $passname"); #change to 'mv'
                        };
        }
        close(DIR);
}


Last edited by jdilts; 11-13-2013 at 12:42 PM.. Reason: ****All is working. \r was need after the password in the expect script. Don't reply. I couldn't figure out how to delete.
# 2  
Old 11-14-2013
Without spawning the perl script in your expect script, could you first check whether the bash scrpt could mount the cifs correctly. I have a feeling it the special characters of your password "AIB#1109$" that makes it fail.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash executes first part of script but not second

My bash below verifies the integrity of all .bam in a directory and writes the out output to a .txt file. That is part one of the script that works. The second part of the bash searches each one of the .txt files for a string "(SUCCESS)" and if found display a message and if it is not found... (6 Replies)
Discussion started by: cmccabe
6 Replies

2. Shell Programming and Scripting

Will shell script executes in sequence

I have a shell script scheduled in cron job to run at every 1 minute which transfers files to remote machine and then move the files to backup folder. cd /u01/app/ftp_tmp sftp user@hostname <<-EOF cd /home/user/ftp mput * bye EOF mv /u01/app/ftp_tmp/* /u01/app/ftp_bkp Now the problem is... (6 Replies)
Discussion started by: Bhavi
6 Replies

3. UNIX for Dummies Questions & Answers

Script partially executes??

Hi All, I am calling a shell script from another shell script, however, it only executes part of it (the echo commands only). What could be some causes for that? For example: ShellScriptA.sh: ... ... ... . ShellScriptB.sh ShellScriptB.sh contents: echo date echo... (7 Replies)
Discussion started by: DBnixUser
7 Replies

4. Shell Programming and Scripting

script executes some time but not always.

I have following script to send email when a USB is attached. #!/bin/bash NUMBER=`/bin/cat /u/numberoflines` LINES=`/usr/bin/wc -l < /var/log/messages` DIFFERENCE=$(($LINES-$NUMBER)) if ; then tail -n $DIFFERENCE /var/log/messages |while read line do if $( echo $line | grep --quiet... (2 Replies)
Discussion started by: kashif.live
2 Replies

5. Shell Programming and Scripting

FTP script - 'quit' never executes

I have wrote a script to get a very large encrypted file from a remote ftp server to a local debian box. The file downloads successfully, but the script never exits, or quits. None of code executes after the ftp get command. The file is approx 291M Here is the code: !/bin/sh... (3 Replies)
Discussion started by: jstrahm
3 Replies

6. Windows & DOS: Issues & Discussions

Batch script executes twice

Hi, Batch script gets executed without any error, but on execution some of the partial contents of the batch file gets appended at the end of the file which is currently in execution, hence the script tries to execute again for the second time , which should not happen. How to get it... (5 Replies)
Discussion started by: milink
5 Replies

7. Shell Programming and Scripting

My script executes too long than expected

Below is my script code which filters failed logins from existing and non-existing users from the server. The problem is, it takes longer to execute and complete than expected. Anyone here can edit the script to speed up its execution. #!/bin/bash LIST=`cat $1` for i in $LIST do... (10 Replies)
Discussion started by: linuxgeek
10 Replies

8. Shell Programming and Scripting

root executes a script as another user

Hi All, Am using the below command to start my application using the root user su - bin -c "/home/bin/test/start.sh" but am getting the error becaue i have set some environment varibales in bin's .profile when i execute the command start.sh by logging directly into bin account it's... (9 Replies)
Discussion started by: ravi.sri24
9 Replies

9. Shell Programming and Scripting

send mail after script finishes running

Hi All, We now have a Log file which has time stamps of all the scripts ran. It has start time and end time. I now have a requirement to send mail to the Admin after the script finishes running. Can some one help me with a Script which will send mail with Start time and End time of the... (2 Replies)
Discussion started by: srikanthgr1
2 Replies

10. Shell Programming and Scripting

root executes a script as another user

we have this script that stops, starts and monitor process scheduler. prcs_control. this script runs perfectly when executed by ps_user. we are now creating a new script that will run this script and is executed by root. this script needs to execute the prcs_control as ps_user because root can... (1 Reply)
Discussion started by: tads98
1 Replies
Login or Register to Ask a Question