You are not logged in.
why o why does this not work... i have tried a million different types of combinations..
1 #!/bin/bash
2
3 tar --create --verbose --file=etc.tar $ETC_FILES
4 ETC_FILES=('/etc/rc.conf /etc/pacman.conf')
5 echo $ETC_FILES
6 exit 0
7
[root@Estergon ~]# ./test.sh
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
/etc/rc.conf /etc/pacman.conf
The ultimate Archlinux release name: "I am your father"
Offline
you ahve to declare ETC_FILES before using it
ETC_FILES=('/etc/rc.conf /etc/pacman.conf')
tar --create --verbose --file=etc.tar $ETC_FILES
Offline
Yup. It works fine when you put those lines in the right order.
Offline
thx.. stupid mistake..
can you help me with this one?
USER_SET=('$HOME/.vim/ $HOME/.vimrc $HOME/.xinitrc')
27 tar --create --verbose --file=user_set.tar $USER_SET
28 exit 0
[root@Estergon ~]# ./test.sh
tar: "$HOME/.vim/": Cannot stat: No such file or directory
tar: "$HOME/.vimrc": Cannot stat: No such file or directory
tar: "$HOME/.xinitrc": Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
[root@Estergon ~]#
The ultimate Archlinux release name: "I am your father"
Offline
USER_SET=('~/.vim/ ~/.vimrc ~/.xinitrc')
27 tar --create --verbose --file=user_set.tar $USER_SET
28 exit 0
Offline
~ is an alias for home directory
Offline
thx, but didnt work:
tar: ~/.vim: Cannot stat: No such file or directory
tar: ~/.vimrc: Cannot stat: No such file or directory
tar: ~/.xinitrc: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
[root@Estergon ~]# cat .vimrc
nmap mm :make <CR>
set number
set expandtab
set tabstop=4
set shiftwidth=4
set autoindent
colorscheme elflord
[root@Estergon ~]#
The ultimate Archlinux release name: "I am your father"
Offline
thx.. stupid mistake..
can you help me with this one?
USER_SET=('$HOME/.vim/ $HOME/.vimrc $HOME/.xinitrc') 27 tar --create --verbose --file=user_set.tar $USER_SET 28 exit 0 [root@Estergon ~]# ./test.sh tar: "$HOME/.vim/": Cannot stat: No such file or directory tar: "$HOME/.vimrc": Cannot stat: No such file or directory tar: "$HOME/.xinitrc": Cannot stat: No such file or directory tar: Error exit delayed from previous errors [root@Estergon ~]#
Use double quotes instead of single ones:
USER_SET=("$HOME/.vim/ $HOME/.vimrc $HOME/.xinitrc")
Offline
$HOME="/home/framki"
USER_SET="$HOME/.vim $HOME/.vimrc $HOME/.xinitrc"
this way i think it works
Offline
what happened before is that u used single quotes
USER_SET=('$HOME/.vim/ $HOME/.vimrc $HOME/.xinitrc')
single quotes are literal representation, without variable substitution
Offline
this means that tar was trying to open a directory actually called $HOME, without making the substitution from $HOME to whatever you set before.
On the other hand, i have no idea why with ~ it didn't work.
Offline
double quotes worked
thx
The ultimate Archlinux release name: "I am your father"
Offline
Now comes the tricky part..
how can i scp the created tar files automatically? or ftp/any kind of transfer..
I would either like it to be uploaded to my googlepages, or my uni account with scp.
thx again
The ultimate Archlinux release name: "I am your father"
Offline
Look into copying ssh keys to the remote server and logging in with remote keys instead of passwords... makes automating that type of thing much easier.
http://wiki.archlinux.org/index.php/Using_SSH_Keys
http://www.debian-administration.org/articles/152
Offline
thx alot!
The ultimate Archlinux release name: "I am your father"
Offline
you are welcome... to open source. Share your knowledge
Offline
Another question,
I want to import all variables from one script into another.. how can i do that?
Figured it should be with source.. but cant make it to work. Can anyone show a working example?
The ultimate Archlinux release name: "I am your father"
Offline
maybe you can do a call or something similar
Offline
Use the export command.
NOTE: Once the variable is in the environment, it can be accessed by the child processes. Note that the parent process will not inherit any variables from the children. This is very dangerous. In scripts, if you are setting variables to be used locally in the script, you won't have to export. But if you wish for those processes your script calls, ie, another script, then you will have to export.
export TEMPVAR=something
Offline
i also think of the possibily of having a list of wiht the variables names:
export MY_VAR_LIST="VAR1 VAR2 VAR3"
example:
#!/bin/bash
echo A=$A
echo B=$B
if [ "$A" != "" ]; then
echo "We got A and B set!";
exit;
else
echo "A and B are empty";
fi
sleep 1
A="1";
B="2";
VARS="A B";
PREFIX=""
for i in $VARS; do
PREFIX="$PREFIX$i="$(eval echo $$i)" "
done
eval "$PREFIX ./test"
this example checks A and B. if it is not set calls itself passing to itself with the variables filled. then it stops.
Offline
in advance to export, with the example below (check the previous page) you can have control of which variables go to each process without having to create global variables.
in disatvange, you are responsible of escaping doble qutoes: "
Offline
The idea is that in one file, I declare variables, which include the packages i would like to install if I reinstall, and a main file which can import these variables and run the script, installing the packages.
I could simply put all variables in one file, but that would be ugly and not structured.
script main: restore.sh
script variables: packages.sh
The ultimate Archlinux release name: "I am your father"
Offline
you could just source in a text document that has
--------------------------------------
# installlist.txt
# Start list of packages to install
pacman -S irssi
pacman -S openssh
pacman -S kde
blah blah blah...... you get the idea
----------------------------------------------------------
In your restore script , call the file, and wherever you "source" it in, it will run.
source /path/to/installlist.txt
something like that ????
Offline
or just have a string in a file:
packages="kde openssh irssi pebrot"
and source that file in, and do:
pacman -S $packages
It'll also be quicker installing them all at once, rather than one by one.
James
Offline
Iphitus, that is exactly what i have been trying to do, but source doesnt seem to work ..
Check it out:
restore.sh:
#!/bin/bash
source packages.sh
echo $TEST
exit 0
packages.sh:
6 TEST="acpid cpufreq biatch"
7 LAPTOP=('acpid'
8 'cpufrequtils'
9 'gnome-power-manager'
10 'powernowd'
11 'synaptics')
and running the restore gives nothing:
[root@Estergon scripting]# ./restore.sh
[root@Estergon scripting]#
The ultimate Archlinux release name: "I am your father"
Offline