Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 ?
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
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).
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.