Click to See Complete Forum and Search --> : Bash scripting


nrmx
11-27-2002, 07:38 PM
I am not too familiar with bash scripting but I have some basic knowledge. I want to setup a script to upload files to my server. But I want to ask the user which file to upload. Can a bash script read user input? If yes, then how can I do that?

devurandomguy
11-27-2002, 07:47 PM
'read'

nrmx
11-27-2002, 07:48 PM
:( I thought there would be a quick way out.

shadowrider
11-27-2002, 07:54 PM
Originally posted by nrmx
I am not too familiar with bash scripting but I have some basic knowledge. I want to setup a script to upload files to my server. But I want to ask the user which file to upload. Can a bash script read user input? If yes, then how can I do that?
this might help (hopefully..:D ) if you didn't know this before.

bash-advance (http://tldp.org/LDP/abs/html/)

nrmx
11-27-2002, 07:57 PM
I did. :D

shadowrider
11-28-2002, 02:41 AM
Originally posted by nrmx
I did. :D oh kool...sorry for the stupid post..hehe...:D

bskahan
11-28-2002, 03:58 AM
here's my screenshot script; it uses ncftp to upload the files.
http://www.etria.com/screens.php

rather than prompting for input, why not just take arguments? $1 shift and all that.

shadowrider
11-28-2002, 04:07 AM
Originally posted by bskahan
here's my screenshot script; it uses ncftp to upload the files.
http://www.etria.com/screens.php

rather than prompting for input, why not just take arguments? $1 shift and all that. wow! nice site...think i'll be spending more time in your site..and actually learn something there:D

nrmx
11-28-2002, 01:32 PM
That is a really cool site.

I have a screenshot script that works fine totally automated. If anyone wants a copy let me know its simple and easy to revise uses curl. I am helping someone dev a site. The Files are constantly being revised (young project). I just want a script that I can execute, then specify a direct path to the local file and forget about it.

nrmx
11-28-2002, 01:59 PM
This should solve my problem.

Getting user inut (http://linuxselfhelp.com/HOWTO/Bash-Prog-Intro-HOWTO-10.html)

I haven't tried it yet. But I think it should work.

shadowrider
11-28-2002, 03:20 PM
Originally posted by nrmx
This should solve my problem.

Getting user inut (http://linuxselfhelp.com/HOWTO/Bash-Prog-Intro-HOWTO-10.html)

I haven't tried it yet. But I think it should work. very nice...
can you launch the "reading user input" like when you first login? or even better before you login.:D

mjquilly
11-28-2002, 07:42 PM
How often do you guys have your script run that uploads your current screenshot? I wrote one myself, but decided to not use it for fear of accidentally having passwords or what not on the desktop at the time of the screenshot.

nrmx
11-28-2002, 08:20 PM
I have nothing on my box that I need to hide and I am not really worried about security. I update once a week.

Hayl
11-28-2002, 08:41 PM
i have ALT-s keymapped to run my script so I can run it fast whenever i want to. here is my script if anyone is interested. it pops up an x window after the file is uploaded telling you if it failed or not.
#! /bin/bash
# ss.sh - takes screenshot and FTPs it to desired server.
# written by dale_d@telusplanet.net
# version 1.01
#
# REQUIRES: curl
#
# Usage ss.sh -i image_name -f ftp_server -u user_name -p password

# Get user options
while getopts ":i:f:u:p:" opt;
do
case $opt in
i) image_name="$OPTARG" ;;
f) ftp_server="$OPTARG" ;;
u) user_name="$OPTARG" ;;
p) password="$OPTARG" ;;
\?) echo 'USAGE: ss.sh -i image_name -f ftp_server -u user_name -p password'
exit 1
esac
done

# Take Screenshot
import -window root ${image_name}

# Transfer the file

# Transfer the file
if curl -T ${image_name} -u ${user_name}:${password} ${ftp_server}
then
xmessage -center "Screenshot transferred successfully."
else
xmessage -center "Screenshot transfer failed."
fi

# End

nrmx
11-29-2002, 01:35 AM
nice script.