LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-29-2015, 03:09 PM   #1
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Script to automate VMWare Tools Install Error: No such file or directory


So I wrote a simple Bash script to try and automate the install of VMWare Tools for all of our RHEL Servers. I was doing multiple commands from the CLI successfully, so I'm trying to automate it. However I continue to get the following error output.

Code:
./vmwaretools_install: line 19: cd: /media/VMWare Tools/: No such file or directory 
 
unmount VMWare Tools Install ISO Before Proceeding...

tar (child): *.tar.gz:  Cannot open:  No such file or directory 
tar (child): Error is not recoverable: exiting now 
tar: Child returned status 2 
tar: Error is not recoverable: exiting now 
./vmwaretools_install:  line 28: cd: vmware-tools-distrib: No such file or directory 
./vmwaretools_install: line28: ./vmware-install.pl: No such file or directory

Here is the code:
Code:
#!/bin/bash 

echo 
echo "Remove Old VMWare Tools First..." 
echo 

/usr/bin/./vmware-uninstall-tools.pl 

echo 
echo "Remove old VMWare Tools Directory and Create New Directory "
echo 
rm -rf /tmp/vmwaretools/* ; mkdir -p /tmp/vmwaretools 

echo 
echo "Mount VMWare Tools ISO from vSphere now"
echo 
read -p "Press [ENTER] to continue VMWare Tools Install Once ISO is Mounted..." 

cd /media/VMWare\ Tools/ ; cp -R * /tmp/vmwaretools 

echo 
echo "unount VMWare Tools Install ISO Before Proceeding..." 
echo 

#umount /dev/sr0 /media/VMWare\ Tools/
eject /dev/sr0 

cd /tmp/vmwaretools ; tar -zxvf *.tar.gz ; cd vmware-tools-distrib ; ./vmware-install.pl

In trying to troubleshoot, I've done the following:

Code:
head -l vmwaretools_install | od -c 

0000000 # ! / b i n / b a s h \n 
0000015
I've also deleted out #!/bin/bash line incase there is an extra space in there that I can't see and then put it back in and still the same error.

I've check permission and set the following:

Code:
chmod +x /root/scripts/vmwaretools_uninstall

ls -l rwxr-xr-x 1 root root
Not sure what else to check at this time.
 
Old 10-30-2015, 08:14 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
What happens if you replace the escape with double quotes?
e.g.
cd "/media/VMWare Tools/"
rather than:
cd /media/VMWare\ Tools/
 
Old 10-30-2015, 08:38 AM   #3
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Tried what you recommended and still getting the following error message.

Code:
./vmwaretools_install: line 19: cd: /media/VMWare Tools/: No such file or directory
I noticed something odd, for some reason my bash script is being copied to /tmp/vmwaretools.

Line 19 in the code is the following:

Code:
19 cd "/media/VMWare Tools/" ; cp -R * /tmp/vmwaretools
So I can't figure out why its coping the bash script into /tmp/vmwaretools?
 
Old 10-30-2015, 09:12 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Quote:
Originally Posted by JockVSJock View Post

I noticed something odd, for some reason my bash script is being copied to /tmp/vmwaretools.

Line 19 in the code is the following:

Code:
19 cd "/media/VMWare Tools/" ; cp -R * /tmp/vmwaretools
So I can't figure out why its coping the bash script into /tmp/vmwaretools?
Because the cd failed but the cp -R * worked (i.e. it copied from your pwd rather than "VMWare Tools" as you were still in pwd when it got to the cp command.
 
Old 10-30-2015, 09:18 AM   #5
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
On your original question when I do a test using either the double quotes or the escape (\) it works in a simple script for me.

That makes me wonder: Did you actually mount the ISO as /media/VMWare Tools before hitting return when you ran the script?
That is your script isn't mounting the ISO but rather asking you to do so then hit return. Presumably you are doing that mount in a separate session. Do you see it mounted when you run "df -h" after the mount? (Maybe you're mount is mounting it as /media/VMWare rather than /media/VMWare Tools because you didn't escape or quote in your mount command line?)
 
Old 10-30-2015, 09:32 AM   #6
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by MensaWater View Post
Because the cd failed but the cp -R * worked (i.e. it copied from your pwd rather than "VMWare Tools" as you were still in pwd when it got to the cp command.
I don't understand why the cd isn't working? Maybe because I have to go back to vSphere and click a button, "Install VMware Tools." That's why I have the read line in the script, so the end user has time to click that button, then press enter on the keyboard to continue the script. Otherwise during the vmware-install.pl it won't complete successfully because the VMware Tools ISO is still mounted.

When mounting the VMware Tools iso, it shows the following:

Code:
/dev/sr0 on /media/VMware Tools type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,ohcharset=utf8,mode=0400,dmode=0500)

Last edited by JockVSJock; 10-30-2015 at 09:46 AM.
 
Old 10-30-2015, 10:18 AM   #7
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
And what does df show after the mount?

What do you see if you do the cd manually after the mount and type pwd?

By the way why cd to the mount anyway? Why not just do:
cp -R "/media/VMWare Tools/*" /tmp/vmwaretools
 
Old 10-30-2015, 11:36 AM   #8
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Code:
df -ha 

/dev/sr0   62M  62M  0  100%  /media/VMware Tools

Code:
# cd /media
# pwd 
/media 
# cd VMware\ Tools/
# pwd
/media/VMware Tools
Since I'm new to this, I thought it was best to change to that directory and cp -R "/media/VMware Tools/*" /tmp/vmwaretools.
 
Old 10-30-2015, 12:23 PM   #9
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Quote:
Originally Posted by JockVSJock View Post
Code:
df -ha 

/dev/sr0   62M  62M  0  100%  /media/VMware Tools

Code:
# cd /media
# pwd 
/media 
# cd VMware\ Tools/
# pwd
/media/VMware Tools

There is a mismatch between your original script and what you are mounting as.
Script has uppercase "W" after VM but what you just wrote shows you're mounting with lower case "w"
i.e. VMWare vs VMware.

Linux is case sensitive so it sees VMWare, VMware, vMware, VmWare etc... all as different names. If you are mounting with the lower case "w" then you should use the lower case "w" in the script.
 
Old 10-30-2015, 01:10 PM   #10
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Well, I posted a response, however I got logged out of the website and lost all of that info.

HOWEVER, I found a solution, which did the trick:

Code:
/bin/bash -c "cp -R /media/VMware\ Tools/* /tmp/vmwaretools"
Looking online, the script isn't having the issue, its the Bash shell. So I had to give the cp command a path to /bin/bash -c. Still not really understanding Globbing files, however if i keep doing these, I will figure it out.

thanks for you help

Last edited by JockVSJock; 10-30-2015 at 01:12 PM.
 
Old 10-30-2015, 01:35 PM   #11
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by JockVSJock View Post
Well, I posted a response, however I got logged out of the website and lost all of that info.

HOWEVER, I found a solution, which did the trick:

Code:
/bin/bash -c "cp -R /media/VMware\ Tools/* /tmp/vmwaretools"
Looking online, the script isn't having the issue, its the Bash shell. So I had to give the cp command a path to /bin/bash -c. Still not really understanding Globbing files, however if i keep doing these, I will figure it out.

thanks for you help
None of that was the problem, the problem was your script was using an upper case W:
/media/VMWare\ Tools
instead of
/media/VMware\ Tools

Your debugging process is very odd...why didn't you just go straight to line 19 and look at why your cd was failing, since that's the part of the script that was failing???

Copy-paste that line from your script into the terminal, see if it fails, why it fails, fix it, and then make that change to the script.

Focusing on execute permissions and character dumps of the shebang makes absolutely no sense to me when the script is failing all the way down on line 19 with a VERY clear error:
Quote:
cd: /media/VMWare Tools/: No such file or directory
Which means either the ISO file is not mounted, or you have an error/typo in your mount location.

Last edited by suicidaleggroll; 10-30-2015 at 01:43 PM.
 
Old 10-30-2015, 01:43 PM   #12
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
One last thing.

There was a globbing issue when it was running the ./vmware-install.pl. I believe this is because these commands are being ran from the Bash Shell Script Vs from the CLI.

I'm running the program as root, along with user and group is root.
 
Old 10-30-2015, 01:45 PM   #13
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by JockVSJock View Post
There was a globbing issue when it was running the ./vmware-install.pl. I believe this is because these commands are being ran from the Bash Shell Script Vs from the CLI.
There is no difference when you run a command inside a bash script versus running it on the interactive bash shell.
 
Old 10-30-2015, 02:21 PM   #14
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by suicidaleggroll View Post
There is no difference when you run a command inside a bash script versus running it on the interactive bash shell.
Then why the Globbing warning/output from their script?
 
Old 10-30-2015, 02:30 PM   #15
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
What warning/output?
 
  


Reply

Tags
bash, vmwaretools


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
VMWare Tools download/install error on Slackware14 64bit ExternalUse Slackware 3 09-26-2013 10:35 PM
Back-Track 5 r2 installing Vmware-tools ./vmware-install.pl gives permission deined LaoK Linux - Newbie 10 01-17-2013 01:11 AM
Linux Shell Script Error: No such file or directory Spoffy Programming 2 04-10-2012 09:05 AM
vmware error: running vmware-config-tools.pl grap-pack Linux - Newbie 1 12-02-2008 01:38 PM
how to execute a script file? Have file/directory not found error sirius57 Linux - Software 2 11-21-2007 11:43 PM

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

All times are GMT -5. The time now is 09:07 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