LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need help with writing a c shell script? (https://www.linuxquestions.org/questions/linux-newbie-8/need-help-with-writing-a-c-shell-script-4175412464/)

Ajit Gunge 06-20-2012 09:24 AM

Need help with writing a c shell script?
 
Hi All,
I want to write a C/perl shell script but I am not sure exactly to go about writing it.This is what how I can expalin you what the script should exactly do.You need not tell me the code but just point me in the direction and tell me the commands that I can use

I have a directory structure where actually the code resides.different file types are in different folders.The basic idea is as follows
When I run the script it should tar the files in the folder them.
Then it should ftp the file to an ip address that I give in a command then it should untar the file in a particular directory structure that is similar to the one that I have tared the file.this I should ideally be able to do in a single shell script.
Please let me know how I can go about writing the script.

Thanks for all your inputs.

pixellany 06-20-2012 10:42 AM

Terminology:
A "shell script" is normally written in the language of the shell. Otherwise you'll simply be writing a "Perl Script"---etc.

As for "C script"--I don't know what that would be---unless it were a shell script running in the "C Shell"


to write the actual script, start by trying all the individual commands. The first thing that jumps out at me is I am not sure that "tar" is available in the ftp protocol. (Uncle Google will know.....)

Next, if you start an ftp client during your script, then you need a way of passing ftp commands to ftp---I assume it's possible, but I've never seen the procedure.

Ajit Gunge 06-20-2012 10:53 AM

Thanks Pixellany.That should get me started

I guess I will write the script in a perl.I want to pass my PWD output as a tar argument.Can you tell me how can I do that in perl.
I quick search in uncle google gave me this link.

pixellany 06-20-2012 12:50 PM

Quote:

I want to pass my PWD output as a tar argument.
Put the output of PWD into a variable, then expand the variable as part of the tar statement---use quoting rules as required.

Quote:

Can you tell me how can I do that in perl.
No

Why not just use BASH?----I don't know PERL, so I'm not really qualified to be asking you this......;)

pan64 06-20-2012 01:33 PM

probably a single rsync command will do this job, you only need to find out the flags you want to use.







__________________________________
Happy with solution ... mark as SOLVED
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.

chrism01 06-21-2012 01:58 AM

For Perl see http://perldoc.perl.org/ & http://www.perlmonks.org/?node=Tutorials, but ftp doesn't support non-ftp cmds like tar.
If you want to do it all in one 'script' then use eg Perl and scp it instead.


All times are GMT -5. The time now is 01:24 PM.