Shamsul Kamal
asked on
bash script
Hi,
I have a question, like to require your assistance, want a bash script which work same like as below mentioned perl script:
========================== ========== ========== ====
#!/usr/bin/perl
my %OPTS = @ARGV;
my $user = $OPTS{'user'};
$task = "mv /backup/cpbackup/daily/$us er.tar.gz /backup-delete/$user.tar.g z";
$contents = `$task`;
exit;
========================== ========== ========== ====
BR
Javaid
I have a question, like to require your assistance, want a bash script which work same like as below mentioned perl script:
==========================
#!/usr/bin/perl
my %OPTS = @ARGV;
my $user = $OPTS{'user'};
$task = "mv /backup/cpbackup/daily/$us
$contents = `$task`;
exit;
==========================
BR
Javaid
Presumably the argumets being passed to your perl script are
perlscript.pl user username
the bash script that savone provided has to be modified to;
If you perl script is called with various arguments for historical reasons and user username are not the only arguments on the line and they are not the first two. Further checks within the bash script have to be done to evaluate each argument to see whether it is the string 'user' and then use the next argument.
perlscript.pl user username
the bash script that savone provided has to be modified to;
#!/bin/bash
task="mv /backup/cpbackup/daily/$2.tar.gz /backup-delete/$2.tar.gz"
contents=`$task`
exit
If you perl script is called with various arguments for historical reasons and user username are not the only arguments on the line and they are not the first two. Further checks within the bash script have to be done to evaluate each argument to see whether it is the string 'user' and then use the next argument.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
superb ozo, yes it's working according to desire results :)
BR
Javaid
BR
Javaid
#!/bin/bash
task="mv /backup/cpbackup/daily/$us
contents=`$task`
exit