Pressing Enter (bash)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pressing Enter (bash)
# 29  
Old 02-11-2009
Quote:
Originally Posted by Corona688
If I understand you correctly:
Code:
DIR=""
while [[ -z "${DIR}" || ! -d "${DIR}" ]]
do
        read -p "Enter dir: " DIR
done

The double-brackets are necessary for the || construct inside.

The non-standard double brackets are not necessary.
Code:
while [ -z "${DIR}" ] || [ ! -d "${DIR}" ]

# 30  
Old 02-11-2009
Quote:
Originally Posted by Yakuzan
How can I write a command right after an echo. It`s not working:

echo "Date : " `date + %d`

Am I writing it wrong?

Hey,

Following is the command to do that: (please take care of the quotes)

echo "Date is : `date +%d` "
Date is : 11


Thanks
Varun GuptaSmilie
# 31  
Old 02-11-2009
Quote:
Originally Posted by varungupta
Following is the command to do that: (please take care of the quotes)

echo "Date is : `date +%d` "
Date is : 11

The quotes make no difference in this case; the error was the space after '+'. Any of these will work:

Code:
echo "Date is : `date +%d` "
echo Date is : `date +%d`
echo "Date is :" `date +%d`
echo 'Date is : '`date +%d`
echo 'Date is : '"`date +%d`"

# 32  
Old 02-11-2009
Thanks for the input guys, Il be working on the file mover in a few days.


Btw, I have a script that deletes directories. I made it so that the user writes the folder that needs to be deleted in the current directory. I even ask a yes/no affirmation.

Now, the problem is that if the directory contains stuff it will give me a beautiful message "Directory not empty" message.

So how the hell do I silence the message that pops out (I checked the man, there's not mkdir silent or something).

If the script notices their is indeed a folder with content in it that it will pop out a message like : "Folder contains stuff ect"

Here's my current bash code:

Code:
clear
echo "---------------"
echo "| 9effacerdir |"
echo "---------------"
echo " "
read -p "Name of file to delete: " choix
echo " "
read -p "Delete? (O/N): " ouinon
if [ -d $choix -a $ouinon = O ]
then
rmdir $choix
echo "<$choix> deleted"
elif [ $ouinon = N ]
then
echo "Destruction of file cancelled."
elif [ ! -d $choix ]
then echo "<$choix> doesn't exist in current directory."
fi
read -sp "Press enter"
echo " "
clear

Anyways, thankks again.

Last edited by Yakuzan; 02-13-2009 at 10:55 AM..
# 33  
Old 02-11-2009
Quote:
Originally Posted by Yakuzan
Thanks for the input guys, Il be working on the file mover in a few days.


Btw, I have a script that deletes directories. I made it so that the user writes the folder that needs to be deleted in the current directory. I even ask a yes/no affirmation.

Now, the problem is that if the directory contains stuff it will give me a beautiful message "Directory not empty" message.

So how the hell do I silence the message that pops out (I checked the man, there's not mkdir silent or something).

You don't; rmdir will not remove a directory that is not empty. Use rm -rf instead.
Quote:

If the script notices their is indeed a folder with content in it that it will pop out a message like : "Folder contains stuff ect"

Here's my current bash code:

Please put code inside [code] tags, not [quote] tags.
# 34  
Old 02-13-2009
Edited my post for CODE tag.

Hopefully Il be able to work on my scripts today. Been doing a lot of HTML and Java hehe Smilie

Btw, I don't want my script to be able to delete a whole directory branch. I just want to warn the user that the directory targeted has files in it by popping a message out. (I got others plans for a directory with content in it)
# 35  
Old 03-03-2009
Bumping, I finished the rest of my menu. I got a question on the xclock command:

How can I run an xclock and if a second one is run a message stating there's already one running in the in background will appear.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script termination without pressing Enter key[nohup]

I have a script in which we have used nohup. Once script is executed it will be terminated only when enter key is pressed. I want the script to be terminated without pressing enter key nohup imqbrokerd -name user_id port 2>1 1>$home_`date` & I am a newbie to shell, Kindly please help (3 Replies)
Discussion started by: Suganbabu
3 Replies

2. Shell Programming and Scripting

Input password to bash script, save, and enter when needed

I am looking for a way to start a script and have it prompt for a password that will be used later on in the script to SSH to another host and to SFTP. I don't want the password to be hard coded. Below is my script with the actual IP's and usernames removed. #!/usr/bin/expect -f... (2 Replies)
Discussion started by: jbrass
2 Replies

3. Shell Programming and Scripting

How to pass enter key or selected character in bash script?

hi, i've bash script thats working... but now i need to add a line....that prompts for user input....like yes and 1 as complete install.... so here's how it looks... $ cd 9200 (cd into directory) $./install (hv to type ./install to run install then ask for) ----do you want to... (4 Replies)
Discussion started by: kernel11
4 Replies

4. Shell Programming and Scripting

Perl - start search by using search button or by pressing the enter key

#Build label and text box $main->Label( -text => "Input string below:" )->pack(); $main->Entry( -textvariable => \$text456 )->pack(); $main->Button( -text => "Search", -command => sub { errchk ($text456) ... (4 Replies)
Discussion started by: popeye
4 Replies

5. Shell Programming and Scripting

Want to write a command that keeps pressing enter key in regular interval

Hi, I m new to linux, can you pls help me to write a command/ script that keeps pressing the enter key in regular interval. Thx, Linux1 (2 Replies)
Discussion started by: mylinux1
2 Replies

6. Shell Programming and Scripting

Pressing enter and script still goes on

i have a bash shell script and i press enter and the script still continues on? how do i stop this (3 Replies)
Discussion started by: gangsta
3 Replies

7. Shell Programming and Scripting

How to enter a return key in bash script?

Hi, I'm porting an install script from AIX to Red Hat (2.6.18-164.el5 #1 SMP) I have this script working in both AIX and HP-UX. The script is a wrapper for a Micro Focus Server Express install program. It responds to the install program questions with a here-now list. Responses includes... (14 Replies)
Discussion started by: duker61
14 Replies

8. Shell Programming and Scripting

Pressing "Enter/Space bar" using Net::TELNET? in Perl

I'm trying to learn how to get my script to execute the enter button when it telnets into a router and the router displays output but you need to press the space bar or enter button to continue displaying my output of the router. How is this done? (0 Replies)
Discussion started by: xmaverick
0 Replies

9. Shell Programming and Scripting

BASH: Any Way to Get User Input Without Requiring Them to Hit the Enter Key?

I'm working on making a menu system on an HP-UX box with Bash on it. The old menu system presents the users with a standard text menu with numbers to make selections. I'm re-working the system and I would like to provide something more akin to iterative search in Emacs. I have a list of 28... (2 Replies)
Discussion started by: deckard
2 Replies

10. UNIX for Dummies Questions & Answers

Pressing backspace key simulates enter key

Hi, Whenever i press the backspace key, a new line appears, i.e. it works like a enter key. :confused: Thanks (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies
Login or Register to Ask a Question