-   Linux - Newbie (
-   -   Shell script user input (

tuckermaddox 08-12-2004 01:31 AM

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 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 ?

btmiller 08-12-2004 01:59 AM

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.



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

for file in `ls $directory/$pattern`
  echo $file
  # actual command is left as an exercise to the reader...

tuckermaddox 08-12-2004 02:10 AM

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).

btmiller 08-12-2004 03:00 AM

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.

tuckermaddox 08-12-2004 03:07 AM

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.

tuckermaddox 08-12-2004 03:14 AM

man i keep forgetting other requirements how would i get this script to pipe that command to the other terminal window?

All times are GMT -5. The time now is 01:34 AM.