Noob. shell script with prompt?

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Noob. shell script with prompt?
# 8  
Old 09-22-2016
Thanx RudiC, I guess im partially dyslexic. Im still getting "-r: is not an identifier"
# 9  
Old 09-22-2016
We can't see your scanner from here, please post your code. Photo or screenshot if you absolutely have to but we have to see it or we're just guessing.
# 10  
Old 09-22-2016
this is what i have typed so far

Code:
#!/bin/sh
echo
echo
echo
echo "usb backup script"
echo
echo  "System will be backed up on USB stick"

read -r -p "files will be overwritten, continue?" CONT
if [ "$CONT" =="y" ]; then
   mkdir /home/patient/backup-`gx125-svr`;
else
   exit;
fi


Last edited by Corona688; 09-22-2016 at 01:49 PM.. Reason: Code tags for code, please.
# 11  
Old 09-22-2016
If you're not in BASH, you don't get read -p.

Most shells should have read -r, you must be in a really old or minimal shell if you don't. Luckily -r isn't mandatory, it just prevents read from handling backslashes.

Also, be careful with spaces inside [ ] brackets. Each separate item must be separated by whitespace.

Code:
printf "Files will be overwritten, continue?"
read CONT
if [ "$CONT" = "y" ]; then
   mkdir /home/patient/backup-`gx125-svr`;
else
   exit;
fi

I don't know what gx125-svr is.
This User Gave Thanks to Corona688 For This Post:
# 12  
Old 09-22-2016
gx125-svr is my hostname
# 13  
Old 09-22-2016
If you can't type it at a prompt and run it, you can't put it in backticks. Just /home/patient/backup-gx125-svr is fine if that's literally what it's called.

If you want to actually look up the hostname, use `hostname`, as that is actually a command. Try running it and see what it does.
# 14  
Old 09-22-2016
Quote:
Originally Posted by Corona688
If you can't type it at a prompt and run it, you can't put it in backticks. Just /home/patient/backup-gx125-svr is fine if that's literally what it's called.

If you want to actually look up the hostname, use `hostname`, as that is actually a command.
Thanx so much.
This User Gave Thanks to TorresGXL For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script prompt for first parameter ($1) then run

I have to run post configuration script like this script file is post_config.sh post_config.sh 1234 #1234 is node ID according to given node ID all script run .. .. But i want to post_config.sh script should ask for node ID then run like this.. post_config.sh #i want to run... (8 Replies)
Discussion started by: Ganesh Mankar
8 Replies

2. Homework & Coursework Questions

Shell Script Password Prompt

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am trying to write a shell script that prompts the user for the password which is "lux" once the correct password... (4 Replies)
Discussion started by: Emin_Em
4 Replies

3. Shell Programming and Scripting

unable to pass value to user prompt from calling shell script

This is my script structure main script calls configure script which needs to be run as a different user and the configure script calls my application installation script. the application instruction script prompts the user for a directory which I need to pass from my main or configure script. ... (4 Replies)
Discussion started by: cmastays
4 Replies

4. Homework & Coursework Questions

Unix Shell Script to prompt customer for name etc

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: How do I create a shell script called 'custinfo' to prompt a customer to enter and display back the following:... (4 Replies)
Discussion started by: SQLScript
4 Replies

5. UNIX for Dummies Questions & Answers

Shell Script to prompt customer for name etc

reposting How do I create a shell script called 'custinfo' to prompt a customer to enter and display back the following: name, age, address, phone number, product, price range. Thanks (1 Reply)
Discussion started by: SQLScript
1 Replies

6. Shell Programming and Scripting

Shell Script to prompt customer for name etc

How do I create a shell script called 'custinfo' to prompt a customer to enter and display back the following: name, age, address, phone number, product, price range. Thanks (1 Reply)
Discussion started by: SQLScript
1 Replies

7. Shell Programming and Scripting

shell script executes program, but waits for a prompt

Sorry, newbie here. I have the following shell script which basically executes the sh-n-body.i686 program a specified number of times. However, before the sh-n-body.i686 begins its calculations it prompts for input from the user. In this case the user would have press ". return" and... (7 Replies)
Discussion started by: lionatucla
7 Replies

8. Shell Programming and Scripting

Can give the input to prompt using shell script

Hi, I want to send input to promt from shell script, this thing is possible. I give the one command `/usr/share/ssl/misc/CA -newreq` it needs some user input like password etc., but i need this input also from shell script but it does not works. `/usr/share/ssl/misc/CA -newreq` <<EOF... (2 Replies)
Discussion started by: Vaibhav Agarwal
2 Replies

9. UNIX for Dummies Questions & Answers

sudo in OS X shell script without password prompt??

I've written a shell script to alter a particular preference file on OS X (10.3.9), which works fine (tested by running the script from the terminal sat in front of the box). Problem is, I now have to run this script remotely across a number of machines via remote desktop, so where I've used the... (1 Reply)
Discussion started by: Brad_GNET
1 Replies

10. Shell Programming and Scripting

script to change shell and prompt

I want to write a shell script which will change the current shell (say from csh to bsh) and my Prompt (say my name) as desired.pls help (1 Reply)
Discussion started by: SHYAM
1 Replies
Login or Register to Ask a Question