Ubuntu :: Bash Script, Take User Input Then Use It As A Path?

Jan 29, 2011

I'm trying to make a script to make it quicker to encode videos.

Code:
#!/bin/bash
echo "Type the path of the video file"

[code]....

View 9 Replies


ADVERTISEMENT

General :: Write A Shell Script Which Will Read The Directory Path As Input From User?

Nov 28, 2010

I am new to writing shell scripts. So, please bare with me. I am currently trying to write a shell script which will read the directory path as input from user and will traverse the Dir tree to find all available audio and video files. I have tried to write as much as I could but I don't know where I am making mistake as I get some files to be audio file which are actully tar balls. On the second note there are some files which video but script shows them to be audio. And, some video files are completely skipped. I am giving the shell script below so that you can see. I am using two external files as source which I am attaching.

Code:

#!/bin/bash
#Let's load the extensions that we want to search for
vdExt=$(cat vdExtList)
adExt=$(cat adExtList)

[code]....

View 5 Replies View Related

Programming :: User Input Bash Script

Apr 28, 2010

I've written a bash script that allows a user to input a directory location to find out the size of the directory. However, if the user inputs a directory and finds its size then inputs another directory then wants to quit, the script asks the user numerous times if he wants to quit!! The script won't exit until the number of times the user looks at a directory is reached! What gives?

Here's the script:

Code:

View 4 Replies View Related

Programming :: Working With User Input In Bash

Jun 2, 2009

I've been using python/bash to help myself automate things for a long time, however I am curious. One reason I use python more is because I don't quite know how to work with user input in Bash, such as getting it to ask for input and wait, and then placing that user input into a command.

Here's an example of a script I use from time to time for converting OGG video files into AVI.

How could I write this same script in Bash? Keep in mind I am mostly self taught, so I am by no means an expert programmer.

Code:

View 3 Replies View Related

Programming :: Bash Script Predefined User Input

Aug 9, 2009

I have a script im having some problems with, what I need is to have the system generate a random password for me and use that password when creating new users to it.

System is Debian Lenny and script is in bash.

The program is znc. I have made it so that it will generate the random password on the shell but the problem is to use it in the bnc software.

To make a password there the command is znc --makepass and look like this:

My question is now if it would be possible to put in the script so it would "answer" when it need those passwords ? the random password that is generated is in a variable called $setpass and is NOT crypted.

Or is there any other software that would be able to generate that md5 string for me ?

View 7 Replies View Related

Programming :: Catch User Input While The Bash Script Is Running?

Oct 30, 2010

How do you catch user input while the script is running? Or, how would you make two scripts run at the same time, but use input from one script to the other? The program I'm trying to make, echos text on the screen continuously, but while thats happening, I want the user to be able to input something, so the program can detect the input and display something else. So I thought maybe I could make two scripts run to do each task.

View 5 Replies View Related

Programming :: Bash - Calling A Specific Variable Based On User Input?

May 3, 2011

I'm trying to call a specific variable based on a user selection. For example:

Code: Select a file:

[1] foo.tar
[2] bar.tar

Enter a selection: I have already coded each possible selection to have its own variable. If the user selects 2 I need to select $SELECTED_TAR2, or if they select 1 I need to select $SELECTED_TAR1 and then do something like this behind the scenes:

Code: cp /home/user/$SELECTED_TAR2 /home/user/backup/$SELECTED_TAR2

I was thinking something like this:

Code: echo "Enter a selection: "
read -e SELECTED_NUMBER
cp /home/user/$SELECTED_TAR$SELECTED_NUMBER /home/user/backup

[code]....

View 2 Replies View Related

General :: Store User Input In A Config File GUI For A BASH Script?

Dec 4, 2010

I'm trying to create a backup script. For my second version, I want to make a GUI that will ask the user three things:

1. which folders should be excluded
2. where to store the backup
3. the user's email

I need to store this input, and later input the values into variables in my script. How do I go about doings this?

View 1 Replies View Related

Programming :: Bash - Read User Input: URLs Without The Enter Key Stroke?

Sep 23, 2010

Here's a challenge I've been struggling for months with:

I have a bash script that reads URL addresses of our internal server and then executes some test commands on them. Something like this:

Code:
read -p "Enter URL: " url
sh execute-what-ever-to $url

After copy-pasting the URL the user taps the enter key and the script proceeds, but here comes the tricky part: I want this to work without the need to press the enter key after copy-pasting the URL.

"read -n" does not work in this case, as the URLs vary greatly in length. However, the URLs always end to the same string. They could be like "http://url1/END", "http://url2/END" and so on. So this ending string "END" could be theoretically used to recognize that the whole URL has been pasted.

View 2 Replies View Related

Programming :: Bash Scripting Handling User Input Sections Automatically?

Jun 17, 2010

I have a system setup script for my Slackware installations that pulls all packages and source files from another machine and sets everything up to be identical between machines. The script works as expected but make it entirely unattended. How do I make the bash script deal with automatically selecting "Yes" for, for example "Install x(Yes/No): " when prompted by a make file?

View 3 Replies View Related

Programming :: Bash Scripting - Taking User Input And Adding It To A Particular Area Of A File?

Jan 12, 2010

in bash scripting...say I want to take the input from a user via a question...I would do this:

Quote:

#!/bin/bash

echo "How large do you want this partition to be in GB (enter only the number)?" read PART_SIZE echo "You want your partition to be $PART_SIZE GB" But I don't want to echo it back to the screen, I want to add it to the content of /etc/fstab. I have been mucking around with sed to find the tmpfs partition in /etc/fstab and add the partition size attribute (this is to use the onboard RAM as a volatile partition)...but am not having any luck...

The portion of /etc/fstab that uses /dev/shm for the tmpfs partition is:

tmpfs /dev/shm tmpfs defaults 0 0

So, if a user says "24" GB to the answer (from above), how do I get it to automatically add that value to the tmpfs partition line in /etc/fstab? So it would look like:

tmpfs /dev/shm tmpfs size=24g,defaults 0 0

I understand that I would also have to come up with a way to put "size=XXg", which I could do with a copied over generic file before this action...then the script would have to find "XX" and replace it with the user's figure...

View 7 Replies View Related

Programming :: Bash Scripting With Sudo / Password Prompt And Accepting User Input?

Jul 30, 2011

I'm creating a bash script to do some tasks for me. I would like the script to be run at a set time of everyday. My first question is if it is possible that if one of the commands in the script requires sudo, is there a way to get around it with out making sudo not require a password. Such as, is there a way to include the password in the script? If that is the case, I can always just set the file as read only by sudo. I've been looking for a way to do this, with no success. if I have a command that wants input, how do I give it to the program. For example, if I want to make a zip file that is encrypted, the command would go as:

Code:

zip -r example * -e

now how would I get the script to insert my wanted password.

View 14 Replies View Related

General :: How To Make BASH Script Yes / No User Input Query Terminate With 3 Invalid Inputs?

Mar 16, 2010

I have a BASH script which at one point asks the user a yes/no question. I want to make it so that if the user types in an invalid input 3 times consecutively then the BASH script will echo an error and terminate with exit status 1.

View 9 Replies View Related

OpenSUSE :: Amarok 4.4.2 - How To Input File PATH

Apr 4, 2010

I upgraded my OpenSUSE 11.2 KDE 4.3.5.x to KDE 4.4.2 and am having a couple of issues. Not sure if I am just a bit stupid or impatient figuring them out or what... In Amarok, I used to be able to input or edit the path name under Files (i.e. Browse Local Harddrive for Content). This allowed me to quickly copy and paste a location from Dolphin / Konqueror etc. into and from Amarok for quick access across multiple applications (Especially when sorting out things). Somehow this is either missing (Not possible anymore) or I am to impatient or stupid figuring this out.

View 2 Replies View Related

General :: Command Path Is In PATH But Bash Does Not Find The Command

Jul 12, 2011

kernel 2.6.21.5, slackware 12.0
GNU bash 3.1.17

Code:

As you can see, /usr/local/bin is in the path. However, bash does not look for nasm in /usr/local/bin.

If I am root, things go well:

Code:

View 16 Replies View Related

Fedora :: Fortran Programs And Long Path Names Input's

Apr 30, 2010

I have a fortran program example call like this:

This call cant run my fortran program because they output to the screen that the file ' ' (empty) cant be loaded!

So the problem is that my program cant see the file in the long path name above ( the real name is a bit more longer). I try with shorts path names , and the program can run, reading the input file.

I googleit for this type of error and only found that bash have limits on the filenames and inputs, so i change them (/usr/local/linux/limits.h or some like) to a very high value (999) ,but no success.

View 3 Replies View Related

Ubuntu :: Bash Wildcard To PATH?

Sep 11, 2010

I have some programs compiled into /opt/programname, and I would like to be able to execute them without typing the full path; I've tried with PATH=$PATH:/opt/*/bin, but with no luck;

View 4 Replies View Related

Ubuntu :: Bash Script With Variables Assigned To Path

Jul 7, 2011

I am trying to create a file, that has a variable assigned to it, in another directory. For some reason when I run the script it creates the file only in my pwd and I cannot for the life of me figure out why.My pwd at the moment is Desktop but it does not matter as I have tried from elsewhere. I have tried the touch command in the following ways (some will be obviously incorrect but I was desperate)and many more as well as the original format listed.

View 1 Replies View Related

Ubuntu :: Bash Script For Each Line Of Input?

Jul 21, 2011

I've written my script so that it reads in the variables $1 $2 $3 $3....$12I have an input file as follows

word1 1 1 2 3 4 5
word2 1 1 2 3 4 5 6
word3 1 1 2 3 4

[code]...

View 9 Replies View Related

Programming :: Setting PATH Alias In Bash?

Jul 15, 2010

I am trying to execute executable files in bash without adding ./ I know there must be an alias to add in .bashrc, that must be something like alias PATH=$PATH:. But this seems not to be working.

View 1 Replies View Related

General :: Extract Only Number In A Path In Bash?

Mar 17, 2011

I've these path:

Code:
xxx/yyy/zzz/0908/aaa/a.txt
xxx/yyy/zzz/0909/aaa/a.txt
xxx/yyy/zzz/0910/aaa/a.txt
fff/ggg/hhh/iii/jjj/0911/aaa/a.txt
fff/ggg/hhh/kkk/0912/aaa/a.txt

and I would like to extract only the number, so that I've get the result

Code:
0908
0909
0910
0911
0911

How can I do it in bash?

View 1 Replies View Related

Programming :: Change Running Path In Bash

Feb 5, 2010

We have a custom app that runs on boot on some older hardware running DSL linux, and their startup manager was quite simple. We purchased some newer Asus eeebox's which run xandros and things are quite stable and run nice with 1 exception.The application only runs from the root (/) location. This box auto logs in as 'user' and there is a /home/user/.kde/Autostart folder where you can stick scripts to run at boot. So I have a start.sh script, and with little bash programming tried things such as;
sudo cd /
sudo /startapp.pl

but the errors start spewing with the basic;can't find data/xyz as it's looking in the local.I thought there was a basic cwd (change working directory) but everything I try just forces the run from that location.Any ideas or suggestions are appreciated, but things like can you change the code, etc. can't be done, so it must be a programming thing. The only other thought I had but not sure, can you do a cronjob with @boot or something, that when the box starts, it can run this job as root and fire off?

View 3 Replies View Related

Programming :: Getting Directory Names From A Given Path In Bash?

Apr 11, 2009

I am programming in bash and really stuck finding directory names. I have a script to find all the .php files on my / partition which will return the whole path. Is there a way to print directory hierarchy with all those values leaving out the forward slashes.

View 10 Replies View Related

General :: [bash] Output Of One Script Is Input Of Another?

Mar 20, 2010

Now, I have one script called "defcon" defcon gets the current DEFCON level and outputs it using echo.

Code:

#!/bin/bash
DEFCON=`curl -s http://members.tripod.com/~Swat_25/defcon.html | sed -n '/^$/!{s/<[^>]*>//g;p;}' | sed '/^$/d' | grep '[12345]$'`
echo "The current DEFCON level is $DEFCON"

The second script ("tweet") updates my twitter account.

Code:

#!/bin/bash
curl -s -u USER:PASS -d status="$@" http://twitter.com/statuses/update.xml > /dev/null

What I want to do is be able to update my twitter account with the current defcon status (this is really more of a learning thing than something I actually want to be doing). The original script for tweet replaced $@ with $1, but if I use:

tweet `defcon`

it only uses the first word in the string, similarly if I used $2 or $3.So I changed it to $@. The normal function still works, but typing:

tweet `defcon`

updates twitter with nothing.

EDIT I should mention the /dev/null is there to catch the output of curl, otherwise it won't run silently. It still updates twitter normally with the send to /dev/null

View 1 Replies View Related

Fedora :: Can't Input Chinese In Bash And Sh,--(fc13)

Dec 29, 2010

i can input chinese in vim ,gvim,gedit ,and also zsh...., but i can't input chinese in bash and sh , i use ibus.

If i login with another account , i can input chinese in bash and sh !

i also diff the locale and env between the two account ,they are nearly the same;

example: when i input chinese ""i type "wq" and space,then bash print :

Display all 4063 possibilities? (y or n)

View 1 Replies View Related

General :: Bash: Input Password Into A Variable?

Aug 22, 2010

I'm basically setting up two sshfs mounts and I have it set up so I run one command but type my password twice.Is there an easy to way to input a password using bash and pass that variable to another process asking for a password?

View 5 Replies View Related

General :: Bash: Auto Input Password?

Aug 28, 2010

When I use the scp command, here is a command prompt "Input password:",Now I want to use a one line command to perform the scp command.I tested the "echo "password" | scp xxx yu@10.xxx.xxx.xxx:/", but failed.

View 2 Replies View Related

Software :: Bash Input Control - Different Numbers ?

Mar 18, 2011

I'm making an bash script.

As input you can input different numbers from 1 to 3.

Depending from the input a text shows up.

View 2 Replies View Related

Programming :: Read Multiple Input With Bash?

May 7, 2010

As I'm starting to learn bash scripting I'm trying to automatize some tasks I usually perform. I have a notification mail I need to send several times a day. It has this structure:

Quote:

Dear user,
blah blah blah blah

You need to contact the following people:

[code]...

To replace "user", I found this:

Code:

read -p "Please enter username: " username
echo "Dear $username,"

Which probe to be very useful with other simple notifications like this. But I don't know how to manage the email addresses as they are usually more than one and could vary from 1 to 10. They should appear one above the other. I found this: "Here is a little work around. The only thing the user needs to do is hit enter without anything else on a line and it will close out"

Code:

#!/usr/bin/ksh
word=a
until [[ $word = "" ]];do

[code]....

I tried to use it and modify for my needs but I failed, I don't realize yet how can I use it. If possible, I would like to use the until loop like the above example just for learning purposes but any other form will be accepted as well.

View 10 Replies View Related

Programming :: Bash - How To Expand Path Variable That Contains Spaces And Wildcards

Feb 15, 2010

having bit of a trouble with path expansion of strings that contain some whitespace and wildcards First my script sources a configuration file that contains array assignments

Code:

...
BACKUP_TARGET_FILES[2]=/boot/config-* # no problems
BACKUP_TARGET_FILES[3]="/root/random dir with space/file*" # this is the problem
...

then later in the script I want to expand BACKUP_TARGET_FILES elements as below

Code:

IFS_DEFAULT="$IFS"
shopt -s nullglob
shopt -s dotglob
IFS=

[code]....

this code seems to work but I'm not quite satisfied with it. I'd like to get rid those IFS changes, but haven't found out a solution as of yet. Problem with default IFS seems to be that with it neither $pattern or "$pattern" work; it either interprets pattern as multiple words (because of spaces) and so expands to wrong paths or it ignores * because it's within quotes.

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved