You are not logged in.
Hi!
I made a small bash script "wp" which upload files from a file list (~/uploads.txt), and comment them from the list when uploading is ready. It writes a log file in "~/uploads.log" and it invokes the program similar to "wget" but called "wput". I public it, maybe it is useful for others too:
#!/bin/bash
if [ -z $(pgrep ^wp$) ]
then
:
else
echo "wp script is already running!"
exit
fi
host="ftp://yourusername:yourpassword@ftp.your_ftp_server.com"
while read f;
do
ret=""
if [ "${f:0:1}" = "#" -o "$f"1 = 1 ]
then
if [ "$f"1 = 1 ]
then
#read command feed a lot of empty string, this line is to deal with them, empty command :
:
else
#first character is a remark sign in uploads.txt # then message -> :
echo "remark line skipped: "$f
fi
else
#while string $ret is empty
while [ -z "$ret" ]
do
wput "$f" --tries=-1 $host 2>&1|tee -a ~/uploads.log
ret=$(tail -n 1 ~/uploads.log|grep "FINISHED\|Nothing\|Skipped\|Transfered")
done
#if $ret is not empty then upload was successful -> comment the line in uploads.txt
if [ -n "$ret" ]
then
cat ~/uploads.txt > ~/uploads_bak.txt
awk -v f="$f" '{if ($0==f && $0!~/#/) print "#" $0; else print $0;}' ~/uploads_bak.txt > ~/uploads.txt
fi
fi
done < ~/uploads.txt
I would like to start this script called "wp" when I login, with this command sequence (avoiding multiple starting):
if [ -z $(pgrep ^wp$) ]
then
echo "starting wp script..."
wp
else
echo "wp script is already running!"
fi
My question is which file should I place this invoking command sequence in to start my script at every login in a terminator / xterm window? Recently I placed it in "~/.bashrc" but I realized it starts when I manually launch terminator / xterm.
Last edited by Konstantin_hu (2013-07-03 16:23:38)
Offline
It depends. have a look at this
Offline
Thx, I have read that article before asking my question, but I still don't know which file to use.
Offline
What DE/WM are you using?
Offline
My question is which file should I place this invoking command sequence in to start my script at every login in a terminator / xterm window? Recently I placed it in "~/.bashrc" but I realized it starts when I manually launch terminator / xterm.
HUH?
You want it to run with *every* terminal you open ... but not with the ones you open manually? Can you clarify that?
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Online
No, I just want it to start once, when I login, in a terminator / xterm window.
Offline
Why when you open a terminal window, why not when you login to your x session?
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Online
That is what he is saying Trilby, when he logs into the computer, he wants it to start a terminal with his script running. What WM/DE are you using Kinstantin?
Offline
If i got it right, you should try exec xterm -c wp to ~/.xinitrc
Last edited by defer (2013-07-03 20:26:24)
Offline
If i got it right, you should try exec xterm -c wp to ~/.xinitrc
"exec" replaces the running process, so if he uses this line before he starts his window manager, the wm won't start.
Before we go telling him how to modify his xinitrc, we need to know if he's even using one. As FlyingHappy has asked (twice now) "What DE/WM are you using?"
How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.
Offline
I am using LXDE.
Offline
LXDE has a built-in autostart mechanism. Use it to start xterm and run your script when you log in.
https://wiki.archlinux.org/index.php/LX … t_Programs
Last edited by 2ManyDogs (2013-07-03 21:18:57)
How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.
Offline
Thx, meanwhile I realized that I can start it as: "terminator -e wp"
Offline
So this is [solved]?
6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.
Offline