LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 11-03-2009, 04:44 PM   #1
targettl
Member
 
Registered: Sep 2009
Location: Launceston
Distribution: Kubuntu
Posts: 84

Rep: Reputation: 16
Running fdisk in a script


I have got a huge bash script and would like to add a fdisk command to it. The problem is that this command requires user input.
fdisk /dev/sda
Then you have to enter "w" and press [enter]

How can I make this process automatic so it won't ask for the w input.
 
Old 11-03-2009, 04:57 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
Can you try and pipe input to it? Something like
Code:
echo w | fdisk /dev/sda

Last edited by nadroj; 11-03-2009 at 05:05 PM.
 
Old 11-03-2009, 05:12 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Usually 'sfdisk' is promoted for scripting things, not 'fdisk'?..
 
Old 11-03-2009, 05:18 PM   #4
targettl
Member
 
Registered: Sep 2009
Location: Launceston
Distribution: Kubuntu
Posts: 84

Original Poster
Rep: Reputation: 16
Very quick response and is the answer I was looking for.
Thank you.
 
Old 11-03-2009, 05:19 PM   #5
targettl
Member
 
Registered: Sep 2009
Location: Launceston
Distribution: Kubuntu
Posts: 84

Original Poster
Rep: Reputation: 16
echo w | fdisk /dev/sda is that answer i was looking for thanks
 
Old 11-03-2009, 05:21 PM   #6
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
One thing to notice is that the output of fdisk (at the very end) is:
Code:
Command (m for help): Command (m for help): Command (m for help): Command (m for help): 
got EOF thrice - exiting..
So theres obviously something not quite right about the method I suggested above. I searched around and saw others with a similar problem. I dont know what "sfdisk", but if its the non-interactive version of fdisk (which is what you would really want), then I would try and play with that. Though if your not worried about these warnings, then it should be ok.

Last edited by nadroj; 11-03-2009 at 05:22 PM.
 
  


Reply



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
boot problem after running fdisk chud1950 Slackware 31 01-19-2008 02:40 PM
What is this error im getting when running fdisk? Dachy Slackware 4 06-07-2005 01:02 PM
why fdisk is not running? AkshatBhandari Linux - Newbie 2 03-18-2005 01:31 PM
running fdisk in linux Lrr Linux - Newbie 11 03-03-2005 12:12 AM
running FDISK Juniper34 Linux - Newbie 2 08-13-2003 07:25 PM

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

All times are GMT -5. The time now is 06:21 PM.

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