LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 08-12-2004, 01:31 AM   #1
tuckermaddox
LQ Newbie
 
Registered: Aug 2004
Distribution: xandros pro business 2.0
Posts: 4

Rep: Reputation: 0
Shell script user input


I'm not new to linux but i am new to writing my own shell scripts and i have a few questions...how would i a: prompt the user to enter the name of a directory and enter that as a variable b: take that variable and use it to list a certain file type ex: *.bndl c: take this and open another program that uses terminal and send the command "upload bundle [user input directory here| bundle name]" and d: do that one at a time until all files from said directory matching the criteria have been uploaded via the script command ?
 
Old 08-12-2004, 01:59 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,128

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
You're post is a little confusing, but the following hacked-together piece of code should do roughly what you want. I've left off the actual upload command since I'm not sure that I understand the syntax you specified.

Code:
#!/bin/sh

echo Enter a directory:
read directory
echo Enter a pattern:
read pattern

for file in `ls $directory/$pattern`
do
  echo $file
  # actual command is left as an exercise to the reader...
done
 
Old 08-12-2004, 02:10 AM   #3
tuckermaddox
LQ Newbie
 
Registered: Aug 2004
Distribution: xandros pro business 2.0
Posts: 4

Original Poster
Rep: Reputation: 0
I know its confusing and I apologize, I have a phone that syncs up through a terminal like app. To upload beta programs to it you type in the command "upload bundle [/example/directory/file.bndl]". Whenever I get a replacement device from my cellco I have to manually do that command: "upload bundle [/example/directory/file.bndl]" for each and every one of the beta programs i have installed which is about 30...thing is the filenames change with each new build and can be like 30 chars long. I'd like to create a script that searches in the specified user inputted directory for all .bndl files and then sends that command to the htconsole program (the program to upload the bndl files to).
 
Old 08-12-2004, 03:00 AM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,128

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
In that case the script I posted should be what you're looking for. The $pattern variable is *.bndl (you can hardcode this). And the actual command line would be:

upload $file [/example/directory/$file]

If you replace the line that says "actual command is left as an exercise for the reader" with this, you should be more or less set.
 
Old 08-12-2004, 03:07 AM   #5
tuckermaddox
LQ Newbie
 
Registered: Aug 2004
Distribution: xandros pro business 2.0
Posts: 4

Original Poster
Rep: Reputation: 0
THANKS A MILLION

thanks i'm going to put this into effect right away and try to learn how it works at the same time. I appreciate your help...Oh yeah and I forgot, I also need to ask them where their developers squash file is and that has the extension of .sq. I need that to be uploaded through the htconsole program first if they need. So that's kind of a conditional there...If they don't have it on their first then uploading bundles is pointless.

Last edited by tuckermaddox; 08-12-2004 at 03:11 AM.
 
Old 08-12-2004, 03:14 AM   #6
tuckermaddox
LQ Newbie
 
Registered: Aug 2004
Distribution: xandros pro business 2.0
Posts: 4

Original Poster
Rep: Reputation: 0
man i keep forgetting other requirements how would i get this script to pipe that command to the other terminal window?
 
  


Reply


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
Shell script pipe input - bash mostly laikos Programming 4 11-09-2008 05:14 PM
help on shell script as a wrapper to launch default programs according to input file daveiro Programming 2 11-24-2005 04:20 PM
how can I take input with a shell script? GUIPenguin Linux - General 4 04-11-2005 03:46 PM
Masking user input in sh script? RMSe17 Linux - Software 3 07-20-2004 10:17 PM
User input using a BASH script... causticmtl Programming 5 07-13-2003 09:59 PM


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