Sponsored Content
Top Forums Shell Programming and Scripting Building a script in Ubuntu (Linux) from existing DOS .cmd Post 302380186 by dp123 on Monday 14th of December 2009 01:05:23 PM
Old 12-14-2009
Question Building a script in Ubuntu (Linux) from existing DOS .cmd

Greetings,
I would be very grateful to anyone who is willing to help and knows there scripting and how to convert a DOS CMD script. Smilie
In this posting I am also hoping to pass on information to anyone wanting to see a bit of VMware command line stuff.
I have made a script (batch file) that runs great in windows but I want to run it on Ubuntu (9.04 64-bit).
The problem is that dividual commands run independently on the command line, but in a script it doesn't. It seems like only the first command runs and the rest don't really work.
I want to know how best to create the script file and run it. I also want to learn on the way.
I don't have the time to learn more shell scripting right now and want to get the job done. I tried to get it to work but it all just behaves strangely.

I created this script to quickly deploy 3 VMware virtual machines (2 are clones from a base image and one gets unzipped). The script does fancy stuff like change the vmnets and adjust the memory and display names of the new VMs. The idea is to use them and then later redeploy them afresh.
I will use something like "/home/administrator/vmware/Virtual Machines" instead of "c:\Virtual Machines" and /usr/bin/vmware instead of vmware.exe

Here is the working DOS script and below some conversion that I have created
===================================================
Code:
@echo off
cd\
cd "Virtual Machines\VMs\"
rmdir England /S /Q
mkdir England
c:
cd\
cd "Virtual Machines\VMs\"
cls
echo.
echo Creating VMs ....
echo.
echo Start time:
echo.
time /T
time /T > timenow.txt
rem ##### PC 1
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" clone "C:\Virtual Machines\VMs\XPVM\Windows XP Pro.vmx" "C:\Virtual Machines\VMs\England\pc1\pc1.vmx" linked
rem the next line looks in the vmx file for clone.... value and replaces with pc1
cscript replace.vbs "C:\Virtual Machines\VMs\England\pc1\pc1.vmx" "Clone of Windows XP Pro" "pc1" 
echo.
echo PC done.
echo.
time /T
echo.
rem ##### pc2
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" clone "C:\Virtual Machines\VMs\XPVM\Windows XP Pro.vmx" "C:\Virtual Machines\VMs\England\pc2\pc2.vmx" linked
cscript replace.vbs "C:\Virtual Machines\VMs\England\pc2\pc2.vmx" "Clone of Windows XP Pro" "pc2" 
cscript replace.vbs "C:\Virtual Machines\VMs\England\pc2\pc2.vmx" "VMnet2" "VMnet3" 
cscript replace.vbs "C:\Virtual Machines\VMs\England\pc2\pc2.vmx" "512" "256" 
echo.
echo pc2 done.
echo.
time /T
echo.
7z e "C:\Virtual Machines\VMs\pc3.7z" -o"C:\Virtual Machines\VMs\England\pc3\" 
"C:\Program Files\VMware\VMware Workstation\vmware-vdiskmanager.exe" -c -s 10240MB -a lsilogic -t 2 "C:\Virtual Machines\VMs\England\pc3\pc3-000001.vmdk" 
echo.
echo pc3 done.
echo.
time /T
echo.
sleep 5
cls
echo.
echo.
rem sleep 10
cls
echo.
echo  The time now is:
time /T
echo     Launching VMware Workstation Console now ....
echo.
echo.
echo Start time was:
type timenow.txt
echo.
time /T
echo.
echo.
echo.
rem cls
echo.
echo All done !
echo.
echo Job complete
echo.
echo.
sleep 30

===================================================
END

Conversions
========


This is the base image being used to make a linked clone, to later be called pc1
/usr/bin/vmrun -T ws clone "/home/administrator/vmware/Virtual Machines/CheckPoint/XPVM/Windows XP Pro.vmx" "/home/administrator/vmware/Virtual Machines/CheckPoint/England/pc1/pc1.vmx" linked


This replaced the vb script (cscript replace (above)) for replacing text values in the file:
rpl "Clone of Windows XP Pro" "pclondon" "/home/administrator/vmware/Virtual Machines/England/pc1/pc1.vmx"

Last edited by dp123; 12-14-2009 at 04:36 PM..
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

DOS Debug for linux

Hi guys. I'm in desperate need of a program that can allow me to write files to different sectors of a disk (floppy), in the same way the DOS Debug program can (with a command such as -w 100 0 0 1 to write the bootsector of the disk). Does anyone know any links or names of programs that could... (2 Replies)
Discussion started by: KrazyGuyPaul
2 Replies

2. Windows & DOS: Issues & Discussions

rediretion and pipes in DOS shell cmd interpreter

Hello, I am trying to accomplish the following. Send the output of a command to the screen (this happens by default) as well as capture the output of the screen to a log file. How can this be achieved in DOS command interpreter syntax. Any ideas/suggesstions/indicators are greatly... (2 Replies)
Discussion started by: jerardfjay
2 Replies

3. Shell Programming and Scripting

Building a Linux like LS for Unix

I'm trying to customize my environment at work in a Unix system. So I'm starting with the ls command... I'd like to make it run as the Linux ls... Even in color, if possible... My first problem is to make the file listing brake in columns... In fact, the actual ls from Unix does this, but... (3 Replies)
Discussion started by: 435 Gavea
3 Replies

4. Windows & DOS: Issues & Discussions

Awk script in DOS and Linux behaves differently :(

Hi, I have an awk script which performs simple operations of variable assignments and finally printing the variables in custom form. BEGIN {FS=OFS="\n"} { v1=substr($0,1,15) v2=substr($0,16,200) v3=substr($0,216,20) print v1 "|" v2 "|" v3 } The input file being processed... (2 Replies)
Discussion started by: vidyak
2 Replies

5. Windows & DOS: Issues & Discussions

How to connect SFTP(Linux) from Windows DOS

I need to write a batch script for file transfer from SFTP to Windows system. SFTP is on Linux system. I kept this code in batch file and executing it.. but not working.. Even i tried from Command prompt like this "open sftp.host.com" but getting error. Can anyone help with the code and tell me how... (15 Replies)
Discussion started by: mohantmk
15 Replies

6. IP Networking

Need to copy file from Linux to DOS.

I have two PCs with Ubuntu 10.4 and DOS 5.0, which are connected with a 9 pins serial cable. I need to copy some files from the Linux box to the DOS box. I tried UUCP but it's too difficult and i didn't found a working client for DOS. Can you help me? Thanks for any reply! (10 Replies)
Discussion started by: mghis
10 Replies

7. Shell Programming and Scripting

Building a DOS .bat file that will root my Droid 2 phone using adb

1. What I am doing? Building a DOS .bat file that will root my Droid 2 phone using adb commands in the .bat file. (Just for the fun of it and to help me learn "stuff".) 2. Problem: Here are the problem steps to accomplish this task manually in an adb shell: adb shell (Prompt is $) cd... (2 Replies)
Discussion started by: chrstdvd
2 Replies

8. Ubuntu

Copy existing Ubuntu to boot from USB

Hello all, I am looking for a way to copy the existing Ubuntu server 12.04 to a USB (with all the packages and such) and make it boot from the USB. I have seen other threads about copying the CD image to the USB, which is not exactly I am looking for. Before I start diving into anything I... (4 Replies)
Discussion started by: br1an
4 Replies
All times are GMT -4. The time now is 03:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy