This forum is in permanent archive mode. Our new active community can be found here.

What programming language is most appropriate for this task?

edited May 2010 in Technology
Hello Programmers of the FRC:F! I need your advice.

About two weeks ago, I was hired as part of the IT department in the College of Engineering and Computer Sciences at my university. We have quite a few computerlabs and when a computer or lab needs to be re-done we use Symantec Ghost over the network to re-image the machine(s). However, if a machine can't boot into windows, we have to use a custom configured flash drive that will boot a free-running version of the ghost client that is configured with the proper NIC driver. We had more than 30 flash drives, each being only 1 of 5 or 6 different configurations for different nics.

I thought this was stupid, so I figured out how to make a multiboot flash drive that held images of all the different configs and used grub to allow a tech to select the proper version for that particular NIC. This eliminated the need to fish around for the right usb drive.

Now that the product is done, I need a way to duplicate these easily. I wanted to image the drive, but imaging didn't carry the bootability.

Here is what I need:
The tech runs the program and the program asks for the letter of the drive to be made into the multiboot drive.
the program then asks to confirm.
The program formats the drive to fat32 using windows' built in formatting utility, using the inputed drive letter as an argument.
The program runs the "make it bootable with grub" program, using the inputed drive letter as an argument.
The program copies all the files over to the drive, preserving directory structure.
Confirmation is provided stating the process is complete.


I tried writing this as a windows batch file, but there really isn't a way to accept a string with batch files.
This program doesn't need a fancy UI, it can be just a command line interface, but it has to be able to run without an interpreter (i.e. Python).

So what programming language should I use to accomplish my goal?


EDIT: And please don't tell me to get a USB duplicator. I've only been here two weeks, I can't requisition something that expensive.

Comments

  • edited May 2010
    C would be fine.
    Assembly!
    Post edited by lackofcheese on
  • C would be fine.
    Assembly!
    I should note that batch files and elementary qbasic is the most experience I've had with non-html programming.
  • edited May 2010
    Well, a batch script would work fine if you accepted the drive letter as an argument to the batch script rather than asking for it. Also, Google reveals some ways of getting user input in a batch script, though they're extremely ugly.
    It would only take very basic C to do what you need, though, so it's worth considering, for the sake of niceness and learning.
    Post edited by lackofcheese on
  • Now that the product is done, I need a way to duplicate these easily. I wanted to image the drive, but imaging didn't carry the bootability.
    So, to get this straight, you wish to duplicate the flash drive with all the stuff onto the other 29 or so flash drives? Try dd. "dd if=[location of original flashdrive] of=[clone of flashdrive on harddrive]" then "dd if=[clone] of=[target flashdrive]". Repeat the last step for all flashdrives. You'd have to do it on a linux distro though, unless Cygwin can do it.
  • Yeah, it looks like he wants something that will run on Windows, sadly.
  • Yeah, it looks like he wants to do it the hard way.
    It's not like dd is on every linux distro liveC--DOH.
  • Yeah, learn the dd command dude.
  • dd will not handle flash drives of different sizes, as it is just a block level copy tool. The simplest thing is the previous suggestion to just have the user provide the drive letter as a command line argument to the script.
  • dd will not handle flash drives of different sizes, as it is just a block level copy tool
    This is true, however, as long as the drive is large enough to hold all the necessary data, this shouldn't be a problem. The drive will just have a lot of inaccessible space if a smaller image is placed on it, no?
  • dd will not handle flash drives of different sizes, as it is just a block level copy tool
    This is true, however, as long as the drive is large enough to hold all the necessary data, this shouldn't be a problem. The drive will just have a lot of inaccessible space if a smaller image is placed on it, no?
    It would likely work. I went with the assumption that if he is making a script so that any tech can create one of these drives, that the tech may own the drive. The tech would not want to use the script if it meant giving up the extra space.
  • The tech would not want to use the script if it meant giving up the extra space.
    This is true, but if it's a boot drive, you wouldn't really be using it for storing anything, so the missing space is no problem. If you want to use it for something other than a boot drive, you can re-format it later.
  • I would beg to differ. If I were an IT tech, I would not want to carry around multiple USB disks. I would have the one bootable drive to fix the unbootable machines, with all the extra utilities on the same disk. It is not as if there is some magic barrier that prevents using the bootable disk for other purposes.
  • I would beg to differ. If I were an IT tech, I would not want to carry around multiple USB disks. I would have the one bootable drive to fix the unbootable machines, with all the extra utilities on the same disk. It is not as if there is some magic barrier that prevents using the bootable disk for other purposes.
    Can you put two partitions on one USB stick?
  • edited May 2010
    I thought about using DD, but here's the thing: Our network is primarily windows based, and, although My box at work dual-boots XP and Ubuntu, I am one of the few linux users. In fact, only 2 labs, out of the 40-some-odd that we have, have linux available. I would want to put this up on one of our primary resource servers so any of our techs could access it.
    I would beg to differ. If I were an IT tech, I would not want to carry around multiple USB disks. I would have the one bootable drive to fix the unbootable machines, with all the extra utilities on the same disk. It is not as if there is some magic barrier that prevents using the bootable disk for other purposes.
    Can you put two partitions on one USB stick?
    Partitions on usb flash drives can cause problems sometimes. Its not optimal...
    Post edited by Victor Frost on
  • ......
    edited May 2010
    Can you put two partitions on one USB stick?
    Yes, you can. USB sticks are just just a storage devices and there is no reason why creating multiple partitions on a USB stick wouldn't work. I for one have done so when I played with putting the Ubuntu LiveCD (over a year ago) on a USB of 1GB and formatted the remaining 300MB for simple storage. Worked without problems.
    dd will not handle flash drives of different sizes, as it is just a block level copy tool.
    dd will handle different drive sizes without problem. It'll just, as Scott already said, leave storage space unformatted when the capacity is larger than the dd-file, though this empty space can just be formatted afterwards iirc, and it'll just give an error saying there's insufficient space when the capacity is smaller.
    It would likely work. I went with the assumption that if he is making a script so that any tech can create one of these drives, that the tech may own the drive. The tech would not want to use the script if it meant giving up the extra space.
    I was under the assumption that the college owned the drives, more precisely, the IT department. These drives have been designated and set up as system restore drives already. If storage space efficiency suddenly becomes an issue they would've already found a solution to the problem earlier. If there is any remaining space on the drive the tech can just partition it no problem, I mean, they're IT tech, they're not incompetent, are they? USA, USA

    EDIT:
    Partitions on usb flash drives can cause problems sometimes. Its not optimal...
    Name one. You're already using GRUB remember?
    Post edited by ... on
  • Partitions on usb flash drives can cause problems sometimes. Its not optimal...
    Name one. You're already using GRUB remember?
    Using grub does not mean I'm using multiple partitions on the flash drive. Grub is just the bootloader I'm using so I can select which image to loaded into memory and booted from. The images are just files.
  • Using grub does not mean I'm using multiple partitions on the flash drive. Grub is just the bootloader I'm using so I can select which image to loaded into memory and booted from. The images are just files.
    That does not answer my question. The GRUB comment was in regards to you already using a bootloader on the drive, regardless of whether you called images on the same partition as GRUB or not.

    Again, name one problem with multiple partitions on a USB stick. I really do wonder what problems you know of. But if all you meant with "It's not optimal" that oh dear a minor amount of storage space is lost for keeping track of the multiple partitions, then you have no real argument.
  • Can you put two partitions on one USB stick?
    Yes, however I know at least on windows XP (and I assume earlier versions) partitions on most USB flash drives will not work. The issue is that there is a flag for "removable media" that is set on most USB flash drives, but not on external USB hard drives. The windows driver when it sees this flag does not expect there to be a partition table and will just present you with a "disk is not formatted" error. I just ran into this the other day with my USB flash drive that had an EFI partition for recovery boot of my hackintosh. Mac and Linux of course have no problem with the partition table. Some USB drives can made to clear the "removable media" flag as well to trick the windows driver.
    dd will not handle flash drives of different sizes, as it is just a block level copy tool.
    dd will handle different drive sizes without problem. It'll just, as Scott already said, leave storage space unformatted when the capacity is larger than the dd-file, though this empty space can just be formatted afterwards iirc, and it'll just give an error saying there's insufficient space when the capacity is smaller.
    This is not "handling different drive sizes", this is ignoring different drive sizes and being lucky that it will work if the disk is larger. :)
  • This is not "handling different drive sizes", this is ignoring different drive sizes and being lucky that it will work if the disk is larger. :)
    I've had no problem with writing a smaller image to a larger usb stick. Then again, I do use Linux.
  • edited May 2010
    This is not "handling different drive sizes", this is ignoring different drive sizes and being lucky that it will work if the disk is larger. :)
    I've had no problem with writing a smaller image to a larger usb stick. Then again, I do use Linux.
    It's the other way around that bothers me. And I'd rather not force everyone in my office to learn to use linux, not that I could. Anyway, Let them use their windows.

    So then. C? Basic? Visual Basic?
    Post edited by Victor Frost on
  • Well, a batch script would work fine if you accepted the drive letter as an argument to the batch script rather than asking for it. Also, Google reveals some ways of getting user input in a batch script, though they're extremely ugly.
    It would only take very basic C to do what you need, though, so it's worth considering, for the sake of niceness and learning.
  • So then. C? Basic? Visual Basic?
    No no, I would not even consider using C, VB or any other compiled language for this. The barrier to entry for just executing a series of external commands in C is just not worth it. This is the type of things that shell scripts (ie batch/cmd files) are good at. A shell script with an argument for the drive letter is simplest. (.cmd files are better, as there is slightly more options available in the syntax of the NT cmd.exe shell then a .bat which runs on the old dos command.com).

    Oh, and in windows 2000 and later shell (cmd.exe) you actually can prompt for data easily. The "set" command can be used to prompt and read a string into an environment variable. For example, set /p mydrivevar="Enter drive name: " would prompt with "Enter drive name: " and wait for user input. Any string typed will be placed in the mydrivevar environment variable which can be accessed in the script with %mydrivevar%. The windows cmd shell is not nearly as easy or flexible as unix shells, but it is usable with a bit of research. Note that the quotes are needed to put a space after the ':', and will not be printed with the prompt.

    If you really don't want to use the shell, then at least stick to the realm of scripting languages. Even on windows there are scripting environments available by default, though I have never really used them. Windows 7 includes the power shell, older versions of windows have the scripting host that uses vbscript/jscript. (I assume that "run without an interpreter" == "run on a windows without installing a new interpreter"?)
  • If you can get the Windows shell to do what you want, it's definitely your best option (other than Linux, as has been said).
  • set /p mydrivevar="Enter drive name: "
    Brilliant. Thanks James, that's exactly what I needed.
Sign In or Register to comment.