LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 07-31-2009, 03:14 PM   #1
Naviathan
LQ Newbie
 
Registered: May 2003
Location: NC
Distribution: Bodhi Linux
Posts: 7

Rep: Reputation: 0
[bash script] automating ntfsresize?


Synopsis: Windows Imaging System script. Windows XP on NTFS containing two partitions on one drive. I have the script I need running beautifully. Manually I've taken care of the resizing, imaging and compressing. The problem comes in when I go to expand the volumes again on the follow up system.

The intent is to create a no user input needed image disk. I've imaged my syspreped/ntfsresized system using dd piped through bzip2. The script I've written partitions the drive in 1/2 unpacks the images and writes them back to the new system using cplbar for progress. Anyhow, all that works perfectly, it images the first half of the first partition, ejects the dvd, requests the second one using a "dialog --msgbox" then I have loop script that runs after the OK button is pressed attempting to mount the cd until df greps a /mnt/cdrom entry then it moves on, does the second half of the first part, the second part then the MBR. After this ntfsresize is run again to expand the volumes into the partitions. This is where I'm having trouble. ntfsresize does not have a quiet/no interaction/all answer y switch and it of course prompts the user to proceed with the expansion on both partitions. I need to circumvent this prompt somehow. My end users that the disks are intended for would probably have a heart attack if the read that message ntfsresize prints to the screen and enter n instead of y. Trust me, these guys are not computer literate and everything on their machines is critical. Any ideas? I'm experimenting with expect scripting for the final steps, but I've read another post where someone had issues with expect and ntfsresize. Any ideas are greatly appreciated.
 
Old 08-01-2009, 11:02 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,746

Rep: Reputation: 458Reputation: 458Reputation: 458Reputation: 458Reputation: 458
You might try piping 'y' to it like this:
echo y | ntfsresize-command
And you might end that line with '&> /dev/null' to suppress any output.
 
Old 08-01-2009, 01:31 PM   #3
Naviathan
LQ Newbie
 
Registered: May 2003
Location: NC
Distribution: Bodhi Linux
Posts: 7

Original Poster
Rep: Reputation: 0
I think piping y would just append a y to the end of the parameters. Also the user would still have to hit enter at some point to get it to move on.
 
Old 08-02-2009, 02:45 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,746

Rep: Reputation: 458Reputation: 458Reputation: 458Reputation: 458Reputation: 458
Try it before rejecting the idea -that is the method used to configure QT in order to automate the acceptance of the license.
 
Old 08-03-2009, 11:52 PM   #5
fericyde
LQ Newbie
 
Registered: Aug 2009
Location: Ohio
Distribution: Ubuntu
Posts: 10

Rep: Reputation: 0
Don't forget about expect.

Run the "autoexpect" command on a trial run with the command you're trying to execute and immediately exit.

It will take care of creepy standard-in type issues that the "echo y | [command]" trick may not be able to handle.

I've found that for small tasks like this one I can usually get the expect script down to 5-10 lines or so (lots of removal of comments helps).

--Paul
 
Old 08-04-2009, 06:28 AM   #6
Naviathan
LQ Newbie
 
Registered: May 2003
Location: NC
Distribution: Bodhi Linux
Posts: 7

Original Poster
Rep: Reputation: 0
Expect worked perfectly. Thanks for the help. BTW piping "y" to ntfsresize caused it append a y to the end of the input and just error out.
 
Old 08-05-2009, 12:21 AM   #7
fericyde
LQ Newbie
 
Registered: Aug 2009
Location: Ohio
Distribution: Ubuntu
Posts: 10

Rep: Reputation: 0
Awesome!

Quote:
Originally Posted by Naviathan View Post
Expect worked perfectly. Thanks for the help. BTW piping "y" to ntfsresize caused it append a y to the end of the input and just error out.
You're welcome -- glad to hear this did the trick.
--Paul
 
Old 08-10-2009, 05:44 AM   #8
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 230Reputation: 230Reputation: 230
Can't test this, so it may be a bad idea; but would '<<< y' work?
Code:
ntfsresize-command <<< y
Or would it have the same effect as the discarded echo y ntfsresize-command suggestion?

I'm sleepy/hazy enough this am I can't even think of a good test I could do here.
 
Old 08-11-2009, 05:59 AM   #9
fericyde
LQ Newbie
 
Registered: Aug 2009
Location: Ohio
Distribution: Ubuntu
Posts: 10

Rep: Reputation: 0
Probably not

< [some file] -- maybe -- but my experience with a lot of redirected input is that if:

# echo [data] | [process]

If the above fails you're in for something timing sensitive, like expect.

Using a here document is most likely going to grant the same results as the above.

Just my $0.02
 
Old 12-05-2012, 09:57 AM   #10
Driadan
LQ Newbie
 
Registered: Jan 2006
Posts: 1

Rep: Reputation: 0
It should be
Code:
echo -e "y\n" | ntfsresize -P <device>
 
  


Reply

Tags
bash, bzip2, dd, imaging, ntfs, ntfsresize, windows


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
Automating Interactive script soupbone38 Programming 1 04-16-2009 09:50 AM
Automating sftp using a shell script bhandu Linux - Newbie 3 07-17-2007 01:56 AM
automating lynx in a shell script yimboli Programming 15 04-04-2007 02:15 AM
Bash Shellscript automating command input JoeneB Programming 3 01-13-2006 01:59 AM
FTP Script (Automating) noodle123 Linux - General 2 10-16-2002 08:17 AM


All times are GMT -5. The time now is 08:54 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration